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

How to get datasource's index in QueryCellStyleInfo?

I have a main table "MainTable" and a nested named "NestedTable", something like this:

+ Group 1 (3)
    -- Item A1
    -- Item A2
    -- Item A3
+ Group 2 (1)
    -- Item B1

All groups "Group X" are in a BindingList named groups.
All items "Item XX" are in a BindingList named items.

Within QueryCellStyleInfo I can identify the record being filled is "Item B1", but how can I get the actual object that represents this record "Item B1"?

I can't use e.TableCellIdentity.RowIndex because it represents the index inside the nested table, in this case "Item A1" would be 0, but my items[0] is "Item A1". I need to get items[3].

How can I do this programmatically?

1 Reply

VK Vinish Kumar K Syncfusion Team February 5, 2013 12:09 PM UTC

Hi Cristiano,

 

Thank you for your interest in Syncfusion Products.

 

We have analyzed your sample to get the record info. The queryCellInfo event refer multiple time in GridGroupingControl. But you can get the record info using the CurrentCelllClick event in GGC. The following workaround is used to get the record info in GGC.

 

Normally in GGC the caption and group drop area also included in row index. So we can’t able to get the record based on the e.Inner.RowIndex.  Because it refers the another records. If we want to get the selected records by passing the index means you could pass the record index based on the following code. Please refer the following code.

 

void gridGroupingControl1_TableControlCellClick(object sender, GridTableControlCellClickEventArgs e)

{

GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex);

GridTableCellStyleInfoIdentity id = style.CellIdentity as GridTableCellStyleInfoIdentity;

Element el = style.TableCellIdentity.DisplayElement;

GridCaptionRow gridCaptionRow = el as GridCaptionRow;

if (gridCaptionRow != null)

{

Record rec = gridCaptionRow.GetCaptionSection().ParentGroup.Records[0];

}

else

{

int index = this.gridGroupingControl1.Table.Records[0].GetRowIndex();

int selectedRecIndex = e.Inner.RowIndex - index;

Record rec1 = this.gridGroupingControl1.Table.Records[selectedRecIndex];

// Get the record of first current selected records if groups are collapsed.

//Record rec = this.gridGroupingControl1.Table.CurrentRecord;

}

 

Please refer the attached sample file also for your further reference. If you have any issue in this code. Please modify the attached sample and please provide the steps to reproduce the issue.

http://www.syncfusion.com/downloads/Support/DirectTrac/103307/GGCgetgroup-729336051.rar

 

Please let me know if you have any other concerns.

Regards,

Vinish Kumar.


Loader.
Live Chat Icon For mobile
Up arrow icon