I have the following WebDataGrid with three columns. Two of the columns use DropDownProvider, the other is a hidden column containing the primary key of the row's data. When the user changes the selection in the StateId dropdown, I need to pass the value in the hidden column to a server-side method that will change the selected value in the LocationTypeId column (the other dropdown). How should I do that?
<iggrid:WebDataGrid id="grdISOGeneralLiabilityModel" runat="server" AutoGenerateColumns="false" EnableDataViewState="true" > <EditorProviders> <iggrid:DropDownProvider ID="DropDownProviderForStateId"> <EditorControl ID="EditorControl4" runat="server" DisplayMode="DropDownList"</EditorControl> </iggrid:DropDownProvider> <iggrid:DropDownProvider ID="DropDownProviderForLocationTypeId"> <EditorControl ID="EditorControl5" runat="server" DisplayMode="DropDownList"></EditorControl> </iggrid:DropDownProvider> </EditorProviders> <Columns> <iggrid:BoundDataField DataFieldName="RatingGLId" key="RatingGLId" hidden="true"></iggrid:BoundDataField> <iggrid:BoundDataField DataFieldName="StateId" key="StateId"></iggrid:BoundDataField> <iggrid:BoundDataField DataFieldName="LocationTypeId" key="LocationTypeId"></iggrid:BoundDataField> </Columns> <Behaviors> <iggrid:Selection CellClickAction="Row" RowSelectType="Single"></iggrid:Selection> <iggrid:EditingCore AutoCRUD="false"> <Behaviors> <iggrid:CellEditing> <ColumnSettings> <iggrid:EditingColumnSetting ColumnKey="StateId" EditorID="DropDownProviderForStateId" /> <iggrid:EditingColumnSetting ColumnKey="LocationTypeId" EditorID="DropDownProviderForLocationTypeId" /> </ColumnSettings> <EditModeActions EnableOnActive="True" MouseClick="Single" /> </iggrid:CellEditing> </Behaviors> </iggrid:EditingCore> </Behaviors></iggrid:WebDataGrid>
Hello Michael,
Thank you for your post.
You can perform the cascading functionality entirely on the client and load the items in the second dropdowneditor provider with loadItems method.
I have attached a sample that is showing exactly this, on SelectionChanged dropdown client event, I populate another dropdowneditor provider based on the selected value. I hope you will benefit from it.
Also there are plenty of example in our forum community, below you will find a suggestion that you might find helpgul:
http://www.infragistics.com/community/forums/t/95778.aspx
Let me know if I may be of further assistance.
I'm not sure you understood my question. I don't need to load items into the second dropdown. The items are already loaded in the second dropdown. I just need to programmatically select one of the items in the second dropdown based on the value of a hidden field (not the first dropdown) in the same grid row when the first dropdown selection is changed by the user. The logic that determines which item to select in the second dropdown is complex and already lives on the server. We don't want to duplicate that logic on the client.
Hello,
I understand that the logic is on the server, although our DropDownEditor providers are accessible only on cell/row editing, and the selected item could not be changed from the server. The cell is associated with the data source value, and on start cell editing, the DropDownEditor provider is initialized in order to help you to manipulate the data, and if the cell value persist in the drop down item list, it will be automatically selected (this is just fyi). As for your requirement, the hidden field is visible on the client too, so it wont be difficult to use it in EnteredEditMode client event. From there you will be able to access the EditorProvider and change the selected item.
When you say your DropDownEditor providers are accessible only on cell/row editing, does that mean only on the client? (because you have some cell/row editing events that can be handled on the server, such as RowUpdating).
So you're saying that what I want to do (i.e., select a specific item in the dropdown depending on other data in the row) must be done on the client, correct? Since I need the existing server logic I mentioned to tell me what item to select in the dropdown, it sounds like I have to call that logic while the page is being built on the server and write its results into some kind of Javascript data structure that your client-side EnteredEditMode handler can access, correct?
I will try to be more specific and clear now.
The provider allows to assign the WebDropDown to a grid's column and have the column's cells to be editable with a value list. When you choose to use DropDownProvider and assign it to a particular ColumnKey, this editor provider will appear every time when you start to edit a cell from the specified column. This means that if you have 25 rows, you wont have 25 DropDownProviers, instead you will have one DropDownProvider, which will be called on cell editing (when the cell start to be in edit mode).
As for your questions:
- the provider is accessible from the server also.
- you can select specific item on the client, and on the server also, although if the value which is associated from the cell, is different, the selected value will be ignored and the cell value will be shown.
I am uploading a sample that is showing how on Page_Load I select the first item of the DropDownProvider, but the cell value is different "Soft drinks, coffees, teas, beers, and ales" and the selection from the page_load event will be ignored.