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.
Unfortunately, activation email could not send to your email. Please try again.

Hide table in gridgroupingcontrol

Thread ID:

Created:

Updated:

Platform:

Replies:

33363 Aug 18,2005 08:35 AM Aug 30,2005 02:43 PM Windows Forms 21
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On August 18, 2005 08:35 AM

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

Administrator [Syncfusion]
Replied On August 18, 2005 09:54 AM

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);

Administrator [Syncfusion]
Replied On August 22, 2005 05:34 AM

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); >

Administrator [Syncfusion]
Replied On August 22, 2005 06:24 AM

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.

Administrator [Syncfusion]
Replied On August 22, 2005 07:13 AM

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.

Administrator [Syncfusion]
Replied On August 22, 2005 07:27 AM

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);

Administrator [Syncfusion]
Replied On August 22, 2005 08:09 AM

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??

Administrator [Syncfusion]
Replied On August 22, 2005 10:28 AM

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

Administrator [Syncfusion]
Replied On August 24, 2005 04:23 AM

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");
>}
>

Administrator [Syncfusion]
Replied On August 24, 2005 06:23 AM

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

Administrator [Syncfusion]
Replied On August 24, 2005 07:51 AM

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

Administrator [Syncfusion]
Replied On August 24, 2005 08:22 AM

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

Administrator [Syncfusion]
Replied On August 24, 2005 08:50 AM

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];

Administrator [Syncfusion]
Replied On August 24, 2005 09:52 AM

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

Administrator [Syncfusion]
Replied On August 24, 2005 10:31 AM

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

Administrator [Syncfusion]
Replied On August 24, 2005 12:53 PM

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

Administrator [Syncfusion]
Replied On August 24, 2005 03:05 PM

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

Administrator [Syncfusion]
Replied On August 24, 2005 08:53 PM

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

Administrator [Syncfusion]
Replied On August 30, 2005 03:02 AM

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

Administrator [Syncfusion]
Replied On August 30, 2005 09:03 AM

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

Administrator [Syncfusion]
Replied On August 30, 2005 10:11 AM

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

Administrator [Syncfusion]
Replied On August 30, 2005 02:43 PM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;