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

Hide table in gridgroupingcontrol

Hi together, I have a dataset with three tables. Now I set the datasource of the gridgrouping control to the dataset object described above. Is it possible to hide a whole table (instead of a row or a column) in the grid. Example: Dataset contains three tables "A", "B" and "C". DataSet mySet = new DataSet(); mySet.Load(....) this.gridGroupingControl1.DataSource = mySet; The grid should only show table "A" and "B" -> Table "C" should be hidden. Any ideas Markus

21 Replies

AD Administrator Syncfusion Team August 18, 2005 01:54 PM UTC

You would remove the relation descriptor from the TableDescriptor.Relations collection. this.gridGroupingControl1.DataSource = ds; GridRelationDescriptor rd = this.gridGroupingControl1.TableDescriptor.Relations["C"]; this.gridGroupingControl1.TableDescriptor.Relations.Remove(rd);


AD Administrator Syncfusion Team August 22, 2005 09:34 AM UTC

Now I tried your suggestion. So when I have four tables in the following order: "A" "B" "C" "D" and I want to hide "C" with your suggestion - also "D" will be removed. And furthermore - how can I add the hidden table again? Any ideas? Cheers Markus >You would remove the relation descriptor from the TableDescriptor.Relations collection. > >this.gridGroupingControl1.DataSource = ds; > >GridRelationDescriptor rd = this.gridGroupingControl1.TableDescriptor.Relations["C"]; >this.gridGroupingControl1.TableDescriptor.Relations.Remove(rd); >


AD Administrator Syncfusion Team August 22, 2005 10:24 AM UTC

I do not see this behavior is this sample. http://www.syncfusion.com/Support/user/uploads/GGC_4tables_59fb0908.zip The only reason that removing C would also remove D that I can think of is that D is not sibling of C, but instead is a child of C. Then removing C would also remove D.


AD Administrator Syncfusion Team August 22, 2005 11:13 AM UTC

Hi Clay, you are right - when I remove it before the grid is painted - then everything is ok. But I want to hide it with a checkbox, while the application is running. So with this scenario when i remove "A", then the whole grid seems to be empty. But when I click inside the control I can see the selection rectangle of "B" "C" ... and so on. I think this is a problem of displaying the changes - What I am doing wrong?? Cheers, Markus >I do not see this behavior is this sample. >http://www.syncfusion.com/Support/user/uploads/GGC_4tables_59fb0908.zip > >The only reason that removing C would also remove D that I can think of is that D is not sibling of C, but instead is a child of C. Then removing C would also remove D.


AD Administrator Syncfusion Team August 22, 2005 11:27 AM UTC

Code like this worked for me. this.gridGroupingControl1.DataSource = null; this.gridGroupingControl1.DataSource = this.ds; GridRelationDescriptor rd = this.gridGroupingControl1.TableDescriptor.Relations["Three"]; this.gridGroupingControl1.TableDescriptor.Relations.Remove(rd);


AD Administrator Syncfusion Team August 22, 2005 12:09 PM UTC

Hmm, ok when I additional add these two lines : this.gridGroupingControl1.DataSource = null; this.gridGroupingControl1.DataSource = this.ds; to my code than it works too. But why do i have to set the Datasource to null and reassign it with my datasource?? And another effect is, that my settings which I made to the removing table before - like background color or settings like: GridTableCellStyleInfo nameStyle = childTD.Columns["A"].Appearance.AnyRecordFieldCell; nameStyle.ImageList = _sampleImgList; are lost after adding it back afterwards??


AD Administrator Syncfusion Team August 22, 2005 02:28 PM UTC

Another option is to adjust the DataSet.Tables collection.
private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
{
	this.ds.Tables.Remove("C");
}


AD Administrator Syncfusion Team August 24, 2005 08:23 AM UTC

This is not possible because my dataset is bound to an xml document - so I get an exception when I try to remove a table from the dataset. I still don''t understand why it is only working when I add the lines this.gridGroupingControl1.DataSource = null; this.gridGroupingControl1.DataSource = this.ds; to every remove or add operation. Another thing is that I get an exception when I add or remove the table very fast and often from the relations - I have already sent a direct-trac message. Cheers, Markus gridGroupingControl.DataSource >Another option is to adjust the DataSet.Tables collection. > >
>private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
>{
>	this.ds.Tables.Remove("C");
>}
>


AD Administrator Syncfusion Team August 24, 2005 10:23 AM UTC

I think the main problem is to update the gridgroupingcontrol after removing a table - how can this be done?? gridGroupingControl1.TableDescriptor.Relations.Remove("C"); Now I put the following line after the remove: gridGroupingControl.Engine.ResetTable(); But this helps only partly. The control is updated ( I see only the other three tables). But the new problem is: NestedTable b = gridGroupingControl1.Table.Records[0].NestedTables["A"]; This call results in an exception an the call with an integer it works: NestedTable b = gridGroupingControl1.Table.Records[0].NestedTables[1]; So the question is - how can I update the gridgroupingcontrol after removing a relation ???? Cheers, Markus


AD Administrator Syncfusion Team August 24, 2005 11:51 AM UTC

Here is a little sample. I can click teh checkbox and then click the button without seeing an exception. DO you see an exception in this sample? http://www.syncfusion.com/Support/user/uploads/GGC_4tables_f9a27bd4.zip


AD Administrator Syncfusion Team August 24, 2005 12:22 PM UTC

Ok Clay, I have modified your example - so when you click on the checkbox twice (the first click for removing table "Three" and the second click for adding table "Three") you get the error. Interesting is the function: checkBox1_CheckedChanged Cheers, Markus GGC_4tables_4203.zip


AD Administrator Syncfusion Team August 24, 2005 12:50 PM UTC

In your code, instead of using: NestedTable c = gridGroupingControl1.Table.Records[0].NestedTables[actDescr.Name]; try int index = gridGroupingControl1.TableDescriptor.Relations.IndexOf(actDescr.Name); NestedTable c = gridGroupingControl1.Table.Records[0].NestedTables[index];


AD Administrator Syncfusion Team August 24, 2005 01:52 PM UTC

Hmm Ok, why doesn''t work the indexer with the name instead of the number?


AD Administrator Syncfusion Team August 24, 2005 02:31 PM UTC

Ok it''s me again, there are still some strange errors in the project. It would be nice if you could take a look at it. When you expand the first column and then click on the checkbox - the application crashes! I think it has something to do with the line: gridGroupingControl1.GetTable(actDef.ToString()).TableOptions.AllowSortColumns = false; in the InitializeGrid() function. So i set a lot of things in this function for every table - e.g. some QueryColWidth events. These events are no longer fired after the checkbox click too. Why? Cheers, Markus GGC_4tables_2_8427.zip


AD Administrator Syncfusion Team August 24, 2005 04:53 PM UTC

Here is a different way to try to do this. Instead of trying to remove the table from the grid, you could collapse it so it only occupies one record, and then set the height of this record to zero. This would hide it without having to change any of the binding which is what is causing the behaviors you are seeing. If this works for you, I think it would be the route of least work if you want to dynamically remove and insert tables into your grid. The would only be a matter of setting row heights to hide and show the tables. To support varying rowheights does mean you have to add a custom engine to your project. You can see a discussion of this in this thread. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=33265 The grid not responding properly to removing and inserting a the relation descriptors is a defect. http://www.syncfusion.com/support/issues/grid/Default.aspx?ToDo=view&questId=672


AD Administrator Syncfusion Team August 24, 2005 07:05 PM UTC

Thank you clay, is it possible that you show me this in the GGC_4tables example - with a little bit code? Cheers, Markus


AD Administrator Syncfusion Team August 25, 2005 12:53 AM UTC

Hiding the nested tables by setting the row height to 0 did not turn out to be as straight-forward as I hoped. Here is something that seems to work in the cases you mentioned without having to call grid.Engine.ResetTable. The idea is to remove and insert the actual nested table instead of the relation descriptor. http://www.syncfusion.com/Support/user/uploads/GGC_4tables_d5f0c1d4.zip


AD Administrator Syncfusion Team August 30, 2005 07:02 AM UTC

Hi Clay, I played around with your suggestion - first it seems working, but when I remove the autosize event something strange happens. Please could you take a look at the example (just click the checkbox and move the mouse over the grid) Kind regards, Markus GGC_4tables_3_9036.zip


AD Administrator Syncfusion Team August 30, 2005 01:03 PM UTC

While I am trying to find a solution for my table hide problem - I think I found a bug. So my actual way to hide the table is to set the row size to "0" which seems to work fine. But when I try my way to hide the table with the new build of syncfusion (3.202.1.722) I got a strange behavior. I have attached two projects (one with references to the "old" libs - 3.202.1.0 and another one with references to 3.202.1.722) So on the first project everything is fine. But on the second one when you expand the first table and click the checkbox (many times) - the first table hides instead of the expected one! Any ideas - It would be great to get a fix of this. GGC_4tables_4_witholdlibs_8633.zip GGC_4tables_5_withnewlibs_9735.zip


AD Administrator Syncfusion Team August 30, 2005 02:11 PM UTC

Here is a variation of your idea that looks up the nested in the DisplayElements right before it tries to set it rowheight. This way, if you expand/collapse tables above the one you are showing/hiding, it finds the right row. (I am using the 3.3RC). http://www.syncfusion.com/Support/user/uploads/GGC_4tables_eb880e25.zip


AD Administrator Syncfusion Team August 30, 2005 06:43 PM UTC

Thanks Clay, that seems to work now. But what I am still interesting in - is this a bug I mentioned above?

Loader.
Up arrow icon