We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Hierarchy with editable fields

As shown in the attached file, we have created an editable grid with first column as an hierarchy and rest of the columns as combo boxes. User can enter values in the combos. 1> Not able to assign text to the cell which has been selected from the combo box ( used of GridQueryCellInfo and e.style.celltype=”comboBox”). 2> I am able to create a tree structure in the grid using the "Virtual Tree Grid" example in Suncfusion samples It works fine the first time when all the parent nodes are populated in the grid, but when the "+" sign on the parent is clicked, rows should be inserted and the data for the children should be fetched. For inserting rows, i have written a code as Grid.Rows.InsertRange( 1, 1 ); but that doesnt work. Please give me a solution for working with a hierarchy in an editable grid.

EditGrid.zip

4 Replies

AD Administrator Syncfusion Team January 16, 2006 10:30 AM UTC

Hi Rohan, The VirtTreeGrid implementation can be done using a CollapsibleDataSource object. To use your own data, you would have to create and populate a CollapsibleDataSource.data using a code similar to that in CollapsibleDataSource.InitData method. Here is a sample which populates the CollapsibleDataSource.data with a data set. And I am also able to assign text to the ComboBox cells in the attached sample. Using the datatable.Rows.InsertAt function you can insert a row and then pass that to CollapsibleDataSource and call CollapseData. Here is a code snippet. DataRow dr = ds.Tables[1].NewRow(); dr[0] = "Inserted Row"; dr[1] = "My Child Name"; dr[2] = "12345"; ds.Tables[1].Rows.InsertAt(dr,8); externalData.InitFromDataSet(ds); gridControl1.ResetVolatileData(); externalData.CollapseData(); this.gridControl1.Refresh(); Regards, Calvin.

CS2.zip


RO Rohan January 17, 2006 09:10 AM UTC

Thank you Calvin. >Hi Rohan, > >The VirtTreeGrid implementation can be done using a CollapsibleDataSource object. To use your own data, you would have to create and populate a CollapsibleDataSource.data using a code similar to that in CollapsibleDataSource.InitData method. Here is a sample which populates the CollapsibleDataSource.data with a data set. >And I am also able to assign text to the ComboBox cells in the attached sample. >Using the datatable.Rows.InsertAt function you can insert a row and then pass that to CollapsibleDataSource and call CollapseData. Here is a code snippet. > >DataRow dr = ds.Tables[1].NewRow(); >dr[0] = "Inserted Row"; >dr[1] = "My Child Name"; >dr[2] = "12345"; >ds.Tables[1].Rows.InsertAt(dr,8); >externalData.InitFromDataSet(ds); >gridControl1.ResetVolatileData(); >externalData.CollapseData(); >this.gridControl1.Refresh(); > > >Regards, >Calvin.

CS2.zip


RO Rohan January 17, 2006 09:18 AM UTC

Calvin, Instead of using ComboBox Control for a cell I am using my own custom control. for this custom control its not assigning selected text to the cellText/cellValue and also its not firing a SaveCellInfo event. Can you explain why does it behave like this for a custom control? >Hi Rohan, > >The VirtTreeGrid implementation can be done using a CollapsibleDataSource object. To use your own data, you would have to create and populate a CollapsibleDataSource.data using a code similar to that in CollapsibleDataSource.InitData method. Here is a sample which populates the CollapsibleDataSource.data with a data set. >And I am also able to assign text to the ComboBox cells in the attached sample. >Using the datatable.Rows.InsertAt function you can insert a row and then pass that to CollapsibleDataSource and call CollapseData. Here is a code snippet. > >DataRow dr = ds.Tables[1].NewRow(); >dr[0] = "Inserted Row"; >dr[1] = "My Child Name"; >dr[2] = "12345"; >ds.Tables[1].Rows.InsertAt(dr,8); >externalData.InitFromDataSet(ds); >gridControl1.ResetVolatileData(); >externalData.CollapseData(); >this.gridControl1.Refresh(); > > >Regards, >Calvin.

CS2.zip


ST stanleyj Syncfusion Team January 17, 2006 11:06 AM UTC

Hi Rohan, The SaveCellInfo does not fire because this control is not designed interactive with the textbox of grid, Whereas the default cellType ComboBox is a combination of button and a ListBox. When the MS comboBox is embedded on the grid, the interaction is only on that control and not on grid. The other way of doing is to go for a custom cell type. You may either derive ComboBoxCellModel and ComboBoxCellRenderer or design from deriving GridDropDownCellModel and GridDropDownCellRenderer. If you have the source then you may refer code from Essential Suite\Windows\Grid.Windows\Src\Base\DropDown\GridComboBoxCellRenderer.cs and Essential Suite\Windows\Grid.Windows\Src\Extensions\CellTypes\GridDropDownGridListControlCellRenderer.cs to create similar celltype. ListBox is used for the dropdown and button is derived from GridCellButton (GridCellComboBoxButton.cs) and comboBox is not directly implemented. After creating the custom celltype, it has to be registered through CellModels.Add function and then this cell type can be implemented. Couple of samples can also be referred, that shows how SaveCellInfo is raised. 1. Syncfusion\Essential Studio\4.1.0.10\windows\Grid.Windows\Samples\CellTypes\CalendarCells(also available in earlier versions). The saveCellInfo is raised as the value of calendar is pushed to the CellValue of the grid in the OnSaveChanges function. 2. Refer this KB and see the onSaveChanges. Let me know if you have any more questions. Best regards, Stanley

Loader.
Live Chat Icon For mobile
Up arrow icon