Embedded DropDown in UltraGrid

I’ve had a ton of places I needed this type of control. If you need to embed a dynamically populated dropdown or combobox in a grid here is a pretty simple ways to do it. This builds on using the dynamic query adapter to pull query results (in this case the BAQ query called “DB_AvailDims”) for use in a dropdown list.

I’ve added UD01 as a child to the QuoteDtl table using the wizard in this Post. I’ve added tab and ultragrid which uses the wizard created edvUD01 view as the datasource for the ultragrid called “eugFeatures”.

Of note, I used the valuelist property from the ActiveRow.Cell. It’s not as fancy as the other drop downs but fit my needs in this instance. I originally had this code posted on the Load_Form action but since it uses the “dum” variable  (aka shortchar02)  from each row, I had to add it to the AfterRowActivate so it would call the query as each row was activated.



//-------------------------- Set Row Value for value list query ------------------------

private void eugFeatures_AfterRowActivate(object sender, System.EventArgs args)
{
  string dum = this.eugFeatures.ActiveRow.Cells["ShortChar02"].Value.ToString();

  DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans);
  dqa.BOConnect();

  QueryExecutionDataSet qeds = dqa.GetQueryExecutionParametersByID("DB_AvailDims");
  qeds.ExecutionParameter.Clear();
  qeds.ExecutionParameter.AddExecutionParameterRow("InputUOM", dum , "nvarchar",false, Guid.NewGuid(),"A");

  dqa.ExecuteByID("DB_AvailDims",qeds);

//Build Drop Down
  ValueList vl = new ValueList();

  if (dqa.QueryResults.Tables["Results"].Rows.Count > 0)
    {
    foreach (DataRow dr in dqa.QueryResults.Tables["Results"].Rows)
      {
      vl.ValueListItems.Add(dr["UOMConvOut_UOMCode"]);
      }
    }

  this.eugFeatures.ActiveRow.Cells["ShortChar03"].ValueList = vl;
}

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值