Hi,
I'm trying to create a parent-child relation between two dropdownlists in two ultragrid columns. The webgrid is bound to a list of objects.
For example: one dropdownlist that contrains carbrands and a second that will contain the cars that are made by the selected brand in the first list. The complication is that both these dropdownlists are bound to the dataobject. (Because the object can both be bound to a specific car type or just a brand type.)
First i tried to do this with valuelists, but it seems that a valuelist has no 'selectedindexchanged' event or something like that. Therefore i cant trigger the second valuelist to rebind to his datasource. Is this possible in any way?
Next i tried to use templatecolumns, like this: (removed some of the markup code for visibility)
<igtbl:TemplatedColumn blablabla<CellTemplate><asp:DropDownList DataSourceID="odsCarBrands" SelectedValue='<%#DataBinder.Eval(Container.DataItem,"Car_Brand_Id")%>' DataTextField="Type" DataValueField="Car_Brand_Id" ID="ddlCarBrand" runat="server" AutoPostBack="true" AppendDataBoundItems="true" OnSelectedIndexChanged="ddlCarBrand_SelectedIndexChanged" /> </igtbl:TemplatedColumn><igtbl:TemplatedColumn blablabla<CellTemplate><asp:DropDownList SelectedValue='<%#DataBinder.Eval(Container.DataItem,"Car_Id")%>' DataSourceID="odsCars" DataTextField="Name" DataValueField="Car_Id" ID="ddlCar" runat="server" AppendDataBoundItems="true"><asp:ListItem Value=""></asp:ListItem></asp:DropDownList><asp:ObjectDataSource ID="odsCars" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetCarsByBrand" TypeName="Car" ><SelectParameters><asp:Parameter Name="BrandId" Type="Int32" DefaultValue="-1" /></SelectParameters></asp:ObjectDataSource></CellTemplate></igtbl:TemplatedColumn>
In the codebehind i handle the selectedindexchanged event by changing the objectdatasource's parameter and databinding the second dropdownlist. This is not very handy but it works a little bit. The problem is: when im trying to update the item i get errors like these:
Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
I'm familiair with there errors because they happen in detailviews as well when you have databound controls in databound controls. Its pretty much impossible to fix this without losing the automatic databinding.
Has anyone tried to do something like this before? Is there some easy way for this i'm overlooking? I cant imagine its this hard with an ultrawebgrid..
I'm very interested in any ideas about this..
Tim
Hi Tim,
The best way to achieve the behavior you are looking for would be to use multiple WebCombo controls as editor providers for your respective columns. In this case you can handle the SelectedRowChanged in order to implement your logic.
The WebCombo may be bound to a data source. In order to bind a WebCombo editor to a column, you need to:
To answer your other question, it is possible to use ValueLists.Truly, there is no SelectedIndexChanged event for columns of type DropDownList, however, you can use the UpdateCell event of the grid in order to handle changed in the selected item in the drop down cell.You will need to check from which column the UpdateCell event was fired. This can be done using: if (e.Cell.Column.Key == "DropDown")where DropDown is the Key assigned to your drop down column. I would, however, recommend the WebCombo approach as it is cleaner.Please contact me if you have any questions.Best Regards,Petar IvanovDeveloper Support EngineerInfragistics, Inc.
I am dealing with similar scenario. My question might be very trivial since i am new to Infragistics.
In my case, first column in the ultraWebGrid is a dropdown and i have some logic in its selectedRowChange event to populate the second column in the ultraWebGrid. The problem that i am facing is that i am finding it difficult to capture the ultraWebGrid row from where it is being fired. I need to know the row index to populate its second colum.
Please suggest.
Hi all,
Apologies for the delayed response.
@ PrachiJain,
In the selectedRowChange handler you can find the index of the (first) selected row using:
e.SelectedRows[0].Index
@ Dev__01
If for all your rows you have a "global" list of all the possible options/values, I can suggest that you handle the BeforeDropDown client-side event of the WebCombo. In the handler function you can hide or show the rows based on your requirements. That way the values for your other rows should not be changed.
You can hide a row in the WebCombo's grid on the client by using for example:
igcmbo_getComboById("WebCombo1").grid.Rows.getRow(1).setHidden(true)
Please tell me if this helps.
Best Regards,Petar IvanovDeveloper Support EngineerInfragistics, Inc.http://es.infragistics.com/support
Hi Peter:
Yes - this helped very much. It eliminates all of the complexity of dynamically populating the combo boxes.
One question I also have is - does a general reference guide for the Infragistics Client-Side API exist?
Thank you!
Please feel free to contact me if you need further assistance.
Best Regards,
Petar IvanovDeveloper Support EngineerInfragistics, Inc.http://es.infragistics.com/support
Hi Dev__01,
CSOM documentation is avaialable for our controls. The documentation can be accessed at:
http://help.infragistics.com/NetAdvantage/ASPNET/2011.1/CLR4.0/
The client side documentation for the WebCombo in particular, can be found at:
http://help.infragistics.com/NetAdvantage/ASPNET/2011.1/CLR4.0/?page=WebCombo_Client_Side_Programming.html
Please let me know if I can be of further assistance.