I am using VS2010 VB.NET with the 2011.1 controls. I need to iterate the rows in a WHDG (in the code behind) and if one of my hidden column values = "Y" then I need to display one of my visible columns as a type DropDownList - Else it will display an empty cell/column. Any help would be apprecated. Thanks!
Hi jdymond,
As far as I can understand you essentially want to be able to set at runtime which cells in a column would be editable (through the dropDownProvider) based on the value for that row in another column. Currently, this cannot be done at runtime as the DropDownProvider is set for a whole column.
You could, however, achieve the desired functionality by handling the CellEditing_EnteringEditMode client side event. In the handler you can implement your logic for checking the value of your hidden column and based on that you can either allow or prohibit the cell from entering edit mode.
Please tell me if this helps.
Petar IvanovDeveloper Support EngineerInfragistics, Inc.http://www.infragistics.com/support
Ok let's start with this... How do I set the column as a DropDownProvider? I am retuning a DataSet and binding it to the WHDG in the code behind. However, I am defining the columns and bands etc in the .aspx page. Let's have two options in the DropDown (Yes and No). I am using VS2010 with VB.NET and the 2011.1 controls. Thanks!
I have created a sample for you which demonstrates the DropDownProvider. The sample uses the Categories table of the Northwind database. In this case the displayed data in the grid is not hierarchical or bound in the code-behind but the principle is the same.
An editor provider may be added by clicking on "Edit Grid Editor Providers" from the grid's smart tag. In the sample I have put two options - Yes and No in the editor's Item collection. The asp markup for adding a provider in the grid is as follows (using the default properties):
<EditorProviders> <ig:DropDownProvider ID="WebHierarchicalDataGrid1_DropDownProvider1"> <EditorControl ClientIDMode="Predictable" DropDownContainerMaxHeight="200px" EnableAnimations="False" EnableDropDownAsChild="False"> <Items> <ig:DropDownItem Selected="False" Text="Yes" Value="Yes"> </ig:DropDownItem> <ig:DropDownItem Selected="False" Text="No" Value="No"> </ig:DropDownItem> </Items> </EditorControl> </ig:DropDownProvider> </EditorProviders>
Once added the provider has to be assigned as the editor for a column. This is done in the behaviors menu by adding a ColumnSetting to the CellEditing behavior. Note that CellEditing has to be enabled for this to have effect:
<ig:EditingCore> <Behaviors> <ig:CellEditing> <ColumnSettings> <ig:EditingColumnSetting ColumnKey="MyDropDownColumn" EditorID="WebHierarchicalDataGrid1_DropDownProvider1" /> </ColumnSettings> <CellEditingClientEvents EnteringEditMode="WebHierarchicalDataGrid1_CellEditing_EnteringEditMode" /> </ig:CellEditing> </Behaviors> </ig:EditingCore>
To demonstrate how your initial question can be answered I have handled the CellEditing_EnteringEditMode in order to enable only cells with an even CategoryID value to be edited.
An illustrative video which shows how to add a DropDownProvider to a data grid step-by-step is available here:
http://forums.infragistics.com/aspnet/media/p/182701.aspx
More samples using editor providers can be found at:
http://samples.infragistics.com/aspnet/Samples/WebDataGrid/Editing-and-Selection/DropDown-Editors/Default.aspx?cn=data-grid&sid=a01f7736-5540-4cb6-9526-873efd65f20b
Please contact me if you need further assistance.
Best Regards,Petar IvanovDeveloper Support EngineerInfragistics, Inc.http://www.infragistics.com/support
Great thanks. After the data has been bound to the grid, What event can I iterate through the grid rows and set the value of each DropDownProvider column?
Hi jgymond,
The DropDownProvider is set on a whole column, therefore its items are shared among all rows.
If you want an implementation in which different rows have different "options" for their dropdown columns, I suggest you take a look at the following discussion:
http://forums.infragistics.com/forums/t/56800.aspx
Best Regards,