二开案例.单据插件.数据表格的单元格的输入焦点设置

【应用场景】通过插件控制数据表格的单元格的输入焦点。
【案例演示】采购订单,明细信息单据体,录入完当前行物料后,焦点自动跳转到下一行的物料编码单元格上。
【实现步骤】
<1>编写单据插件,如下图所示。
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel;
using Kingdee.BOS.JSON;
using Kingdee.BOS.Util;
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;
namespace Jac.XkDemo.BOS.Business.PlugIn
{
/// <summary>
/// 【单据插件】数据表格的单元格的输入焦点设置
/// </summary>
[Description("【单据插件】数据表格的单元格的输入焦点设置"), HotUpdate]
public class EntryGirdCellSetFoucsBillPlugIn : AbstractBillPlugIn
{
public override void EntryBarItemClick(BarItemClickEventArgs e)
{
base.EntryBarItemClick(e);
if (e.BarItemKey.EqualsIgnoreCase("tbGetEntryCurrentRowIndex"))
{
this.View.ShowMessage("当前选中行:" + (this.Model.GetEntryCurrentRowIndex("FPOOrderEntry") + 1));
}
}
/// <summary>
/// 捕获物料编码的值更新事件
/// </summary>
/// <param name="e"></param>
public override void DataChanged(DataChangedEventArgs e)
{
base.DataChanged(e);
if (e.Field.Key.EqualsIgnoreCase("FMaterialId"))
{
// 物料编码赋值成功后,输入焦点下移
if (e.NewValue != null)
{
var currentRowIndex = this.Model.GetEntryCurrentRowIndex(e.Field.EntityKey);
if (currentRowIndex < 0)
{
// 焦点行异常,不予处理
return;
}
var newFocusRowIndex = currentRowIndex + 1;
if (newFocusRowIndex > this.Model.GetEntryRowCount(e.Field.EntityKey) - 1)
{
// 新行尚未创建,没法设置焦点了
return;
}
SetFocus(this.View, e.Field.EntityKey, e.Field.Key, newFocusRowIndex);
//SetFocusRowIndex(this.View, e.Field.EntityKey, e.Field.Key, newFocusRowIndex);
}
}
}
/// <summary>
/// 设置焦点行(方式一)
/// </summary>
/// <param name="view"></param>
/// <param name="entryKey"></param>
/// <param name="rowIndex"></param>
/// <param name="fieldKey"></param>
private void SetFocus(IDynamicFormView view, string entryKey, string fieldKey, int rowIndex)
{
var grid = view.GetControl<EntryGrid>(entryKey);
二开案例.单据插件.数据表格的单元格的输入焦点设置
声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。如若本站内容侵犯了原著者的合法权益,可联系本站删除。



