开发者

Combobox in a DataItemTemplate

In the AspxGridView there are two comboboxes in DataItemTemplate, manually loaded. So when user selects one field of the first combo second will be disabled, i wrote this:

<dxe:ASPxComboBox ID="cmbEqualNotEqual" runat="server" 
                                                ClientInstanceName="cmbCEqualNotEqual" EnableClientSideAPI="true">
                                                <Items>
                                                    <dxe:ListEditItem Text=" " Value="0" />开发者_如何学运维
                                                    <dxe:ListEditItem Text="Eşittir" Value="1" />
                                                    <dxe:ListEditItem Text="Eşit Değildir" Value="0" />
                                                </Items>
                                                <ClientSideEvents SelectedIndexChanged="function(s,e){
                                                    alert(s.GetEnabled());
                                                    var selectedIndex = s.GetSelectedIndex();
                                                    if(selectedIndex == 2)
                                                    {
                                                        cmbCBiggerSmaller.SetEnabled(false);
                                                    }
                                                }" />
                                            </dxe:ASPxComboBox> 

But this code disables the combo at the last row, not the row user works on. How can i disable the row user works on?

Thanks


I answer it for myself:

 for (int i = 0; i < grid.VisibleRowCount; i++)
  {
     ASPxComboBox combito = grid.FindRowCellTemplateControl(i, grid.Columns[2] as GridViewDataColumn, "combito") as ASPxComboBox;
     //combito.Value  
  }


The problem appears because the ClientInstanceName property is set for all editors in the same column to the same value. A possible solution is to handle the HtmlRowCreated event of the ASPxGridView and set the ClientInstanceName for both editors to a unique value. Also, in this event handler you should write the client side SelectedIndexChanged event handler. Finally, to obtain an editor instance, use the ASPxGridView's FindRowCellTemplateControl method.

Also, the following article can be helpful to you:

http://www.devexpress.com/Support/Center/ViewKBIssue.aspx?kbid=K18282

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜