Hi,
Using server side code, is it possible to set drop-down's at cell level while webdatagrid is in cell editing mode?
If yes, please share sample code base to achieve the below:
Eg: Set drop down at 4th row, 3rd cell using one collection, then set drop down using a different collection at 6th row 3rd cell etc..
Thanks,
Aravind
Hello Aravind,
You can take a look at this forum topic, where the same functionality has been discussed:
https://www.infragistics.com/community/forums/f/ultimate-ui-for-asp-net/56800/different-dropdownprovider-data-items-for-each-grid-row
There is also a sample code.
If you need further information concerning this matter, let us know.
Nick,
The example code in the link you shared doesn't show logically how you can achieve the below using template column's. Please provide a sample code to achieve the below.
Assume a Grid with 5 rows and 4 column's
In read mode the 4th column shows a non-drop down read only value.
4th Column becomes a drop-down type upon cell editing mode.
Row 1, 4th cell populate with collection 1(Eg: 1,2,3) in edit all mode
Row 2, 4th cell populate with collection 2(Eg: Cake, Bread, Butter) in edit all mode
Row 3, 4th cell populate with collection 3( Eg: Car, Scooter, Bike) in edit all mode
Row 4, 4th cell populate with collection 4(Eg: Norway, Ireland, USA) in edit all mode.
Row 5, 4th cell populate with collection 5(Poocha, Eli, Peruchazi) in edit all mode.
Note:
In real world in our grid, we populate the drop-down for each row using another column value in the grid being passed to back end to retrieve a collection and then bind to the individual cell's as in the above example in edit all mode.
Also we dynamically populate the data to the grid using databind and datasource.
Hello Aravind,The sample in the forum post demonstrates how to use DropDownProvider or WebDropDown.You can have different DropDownProvider DataSource for each row of a WebDataGrid.It works by handling the client-side DropDownOpening event, which calls loadItems, which triggers the server-side ItemsRequested event.During the ItemsRequested event handler, the DropDownProvider's EditorControl (which is a WebDataGrid) is bound with new data.The DropDownProvider is one per column, in example of the forum post the WebDropDown control is loaded every time when a cell from the column enters in edit mode. The items can be kept in the viewstate and this is achievable only through WebDropDown in a templated column.You will need to handle the WebDropDown's client opening event and use it to loadItems() and WebDropDown's server side OnItemsRequested to bind the dataSource.For example:
function WebDropDown1_DropDownOpening(sender, eventArgs) { if (sender.get_items().getLength() == 0) { sender.loadItems("", false); } }
protected void WebDropDown1_ItemsRequested(object sender, DropDownItemsRequestedEventArgs e) { Control webDropDown = (Control)sender; TemplateContainer container = (TemplateContainer)webDropDown.Parent; GridRecordItem item = (GridRecordItem)container.Item; GridRecord row = item.Row; DataTable dt = SampleData.GetShadeDataTable(); int colorId = (int)row.Items[0].Value; // find the shades that match the passed ColorId DataRow[] shades = dt.Select("ColorId = " + colorId.ToString()); for (int i = dt.Rows.Count - 1; i >= 0; i--) { if (!shades.Contains(dt.Rows[i])) { dt.Rows.RemoveAt(i); } } WebDropDown wdd = (WebDropDown)sender; wdd.Items.Clear(); wdd.DataSource = dt; wdd.DataBind(); }