This is a migrated thread and some comments may be shown as answers.

Need to implement dropdown contain check box value and after selecting save immediately

1 Answer 50 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Samir Patel
Top achievements
Rank 1
Samir Patel asked on 26 Apr 2011, 02:25 PM
Hello,

I have implemented one drop down in the Grid , and this drop down contain the values with check box, so that user can select multiple value from drop down, and i want to save once i lost the focus from this drop down, and the selected values are displayed in the other column of the same grid..

Let me know how can i do this?

Regards
samir

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 Apr 2011, 09:24 AM
Hello Samir,

You could achieve this by attaching OnClientDropDownClosing to the RadComboBox. Here is a sample code to achieve the same.
Client side:
function OnClientDropDownClosing(sender, args)
     {
        var comboBox = sender;
        var grid = $find("<%=RadGrid1.ClientID %>");
        var MasterTable = grid.get_masterTableView();
        var items = comboBox.get_items();
        for (var i = 0; i < items.get_count(); i++)
        {
            if (items.getItem(i).get_element().innerHTML.indexOf("CHECKED") > 0) //checking whether the item is selected or not
            {
                var index = comboBox.get_attributes().getAttribute("Index");//index of the corresponding row which is set from ItemCreated event of the RadGrid.
                var row = MasterTable.get_dataItems()[index]; //accessing the row
                var cell = MasterTable.getCellByColumnUniqueName(row, "ColumnUniqueName");
                cell.innerText += items.getItem(i).get_text();
            }
        }
    }

Attach the ItemCreated event to the RadGrid and add the Corresponding rowIndex as attribute as shown below.
C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
  {
   if (e.Item is GridDataItem)
      {
          GridDataItem item = (GridDataItem)e.Item;
          RadComboBox combo = (RadComboBox)item.FindControl("RadCombo1");
          combo.Attributes.Add("Index", e.Item.ItemIndex.ToString());
      }
   }

Thanks,
Shinu.
Tags
ComboBox
Asked by
Samir Patel
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or