GDBG - Slave combo using different DataSource

I have a slave combo column in a GDBG that can have different DataSource considering the item selected in another column (master combo). My slave combo is not only a filtered view of the original table as explained in the article http://www.syncfusion.com/Support/article.aspx?id=567. The DataSource of my slave combo is a different table in the DataSet with a different ValueMember and DisplayMember for each value that can be choosen in the master column. I tried to override OnCurrentCellShowingDropDown() but it didn''t work. Is there a way to do it? Thanks, Steve

4 Replies

AD Administrator Syncfusion Team September 28, 2004 05:56 PM UTC

You can try handling grid.Model.QueryCellInfo. In your handler, when e.RowIndex and e.ColIndex point to the slave cell, you can then set e.Style.DataSource, e.Style.DisplayMember and e.Style.ValueMember to what ever it should be based on the value in the Master combo. You will probably want to cache all the datatables that you need so you do not try to do some time consuming operation (like a SQL query) to get the desired datatable in QueryCellInfo. In QueryCellInfo, your operations should be just lookups whenever possible.


SG Steve Gauthier September 29, 2004 11:41 AM UTC

Thanks. And how can I access to my master combo value directly from the DataTable instead of using the e.RowIndex and the index of the master column in my QueryCellInfo handler? I want to re-use my derived grid class in a few different dialogs and the master column will not be at the same position for all the forms showing this grid. Moreover for some forms the master column will not be shown. Steve


AD Administrator Syncfusion Team September 29, 2004 12:12 PM UTC

If you are not supporting sorting, then you can get the row position and col position in the datatable using: int rowPos = this.grid.Binder.RowIndexToPosition(e.RowIndex); int colPos = this.grid.Binder.ColIndexToField(e.ColIndex); object val = dataTable1.Rows[rowPos][colPos]; If you are supporting sorting then you need to access the values through the CurrencyManager. CurrencyManager cm = (CurrencyManager) this.grid.BindingContext[this.grid.DataSource, this.grid.DataMember]; int rowPos = this.grid.Binder.RowIndexToPosition(e.RowIndex); int colPos = this.grid.Binder.ColIndexToField(e.ColIndex); object val = ((DataRowView)cm.List[rowPos])[colPos];


SG Steve Gauthier September 29, 2004 03:58 PM UTC

Thanks for your support. It''s working perfectly! Steve

Loader.
Up arrow icon