I have a WebDataGrid where the first field uses a dropdown provider. Whenever the user selects an item from the dropdown, I need to automatically select an item in another dropdown field and set 2 other fields, depending on what was selected. I need to be able to get a record from the database for the selected item to determine what the other fields should be. Is there a way to call a server method when the user selects from a dropdown where I can determine what was selected and be able to set the other fields? If not, what is the best way to accomplish this?
Thanks,
Jeff
Hello Jeff,
Thank you for the details provided. Refer to the link below that will give more details on how to cascade WebDropDown control:
<http://help.infragistics.com/NetAdvantage/ASPNET/2011.2/CLR4.0/?page=WebDropDown_Cascading_WebDropDown_Controls.html>
The same approach can be taken from the dropdownprovider.
I hope this helps.
I am not sure how to use the example with a DropDownProvider. How do you specify the ItemsRequested server-side event for the DropDownProvider? Also, I want to set the selected item for one row. Using the example, it would just change the items in the list and it would be for all rows.
I was able to see that items in dropdown open near the upper left part of the window. I modified the code as shown below:
function WebDataGrid1_DropDown_ItemsRequested(sender, eventArgs) { if (document.readyState != "complete") { window.setTimeout("WebDataGrid1_DropDown_ItemsRequested()", 500); } else {
var grid = $find("WebDataGrid1"); var item = grid._editorProviders._items[1]._editor.get_items().getItem(0); grid._editorProviders._items[1]._editor.selectItemByIndex(0, true, true); } }
It still opens dropdown near the upper left part of the window briefly. I am looking in to this behavior. I have opened a new private support case CAS-102672-J0F0P5 for you. I will update you further with more details on this support case.
Attached is your sample, modified to show the problem.
In order to look in to this please provided me with the modified sample I have provided on Tue, Oct 23 2012 1:55 PM that demonstrates this behavior.
I am not able to get this to work. I am using the ExitingEditMode client event with the following code to fire the ItemsRequested server event for a different column.
if (eventArgs._editor._id == 'WebDataGrid1_Project_Provider') { //eventArgs._editor.loadItems(previousCell.get_text()); var grid = $find("WebDataGrid1"); grid._editorProviders._items[2]._editor.loadItems(previousCell.get_text()); }
Currently, the ItemsRequested server side event does nothing. It will get the default value to be selected from the database. In the client side ItemsRequested event for the field that I want to set the selected value for, I have the following:
var grid = $find("WebDataGrid1"); grid._editorProviders._items[2]._editor.set_activeItem(grid._editorProviders._items[2]._editor.get_items().getItem(1));
What is happening is the dropdown for this field opens near the upper left part of the window. It does have the desired item highlighted. When selecting anything from that dropdown list, the dropdown disappears, but nothing is changed in the grid. If I click in other cells, I can updated them, but the dropdown stays visible until I select an item in the list.
You can handle ItemsRequested event on the client side of the dropdown provider which fires after server side ItemsRequested event fires and before page loads. In this event you can get the instance of editor provider and set the active item in the drop down provider based on your requirements.
var cellindex;
function loadDropDownItems(sender, args) { cellindex= args.getCell().get_index(); if (cellindex == 2)
{ var previousCell = args._cell._row.get_cell(args._cell.get_index() - 1); if (args._editor._id == 'WebDataGrid1_provider2') { args._editor.loadItems(previousCell.get_text()); } } }
function WebDataGrid1_DropDown_ItemsRequested(sender, eventArgs) { var grid = $find("WebDataGrid1"); grid._editorProviders._items[1]._editor.set_activeItem(grid._editorProviders._items[1]._editor.get_items().getItem(1));
}
I have hard coded some values in the above code. You can use cellindex variable to set selected items.