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

Setup Lookup column

I want to setup lookup by foreign key reference
I got two project:
The SetLookup() in GGC_ForeignKeyReference.sln works, but SetLookup() in GGC_SummaryRow_Custom.sln does not work. It got error in line:
td.VisibleColumns.Insert(lookUpIndex, foreignDisplayColInMainTable);

The code SetLookup()are same in both project.

I can't figure out the reason why. Any idea?
Thanks,


Lan





Temp8.zip

7 Replies

AD Administrator Syncfusion Team February 15, 2007 09:58 PM UTC

Hi Lan,

The reason is that you are modifying the column descriptor before adding the relation.( In your sample, you are setting the HeaderText of the 0th column to Identity). When the column descriptor is modified, it does not repopulate the columns after adding the relation to tabledescriptor. If you want to repopulate the column then you need to call the LoadDefault method explicitly. Here is a code snippet.

//step 5. add relation descriptor to main tabledescriptor
td.Relations.Add(rd);
td.Columns.LoadDefault();

Please refer to modified sample for implementation.
Temp8.zip

Best regards,
Haneef


AD Administrator Syncfusion Team February 16, 2007 07:03 PM UTC

Hi Haneef,
Thanks for help. Now the lookup column works well.

Now I got another problem. In the sample, the button 'Button1' is to export the grid to excel.
It uses GroupingGridExcelConverterExt.cs which I got from my previous post:
http://www.syncfusion.com/support/forums/message.aspx?&MessageID=55635

If you click the button1 to export Grid to excel, It will get error now. Any idea?


Lan




AD Administrator Syncfusion Team February 16, 2007 09:04 PM UTC

Hi Lan,

I have modified the ExportColumnHeader method in GroupingGridExcelConverterExt.cs file. Please try the attached sample and let me know if this helps.

[C#]
if( arrColumns.Contains(column.Name))
range.Text = arrColumns[column.Name].HeaderText;
else
range.Text = column.Name;

Here is a sample.
Temp8Modified.zip

Best regards,
Haneef


AD Administrator Syncfusion Team February 16, 2007 10:02 PM UTC

Thanks for help. It works well for me now.


AD Administrator Syncfusion Team February 19, 2007 06:03 PM UTC

Hi,
I got more question.
In your modified sample:
GGC_SummaryRowExport_2605fc15

If you group by state or country, then click 'button1' to export to excel. You will get error in line:
private int ExportRecordRow( RecordRow row, IWorksheet sheet, int index, ConverterOptions options
, int iIndexInGroup, int iGroupLevel, out int iSkipRecordRows )
{

....
GridTableControl tc = engine.GroupingControl.GetTableControl(table.Name);
GridTableCellStyleInfo cellStyle = t.GetTableCellStyle(row, column.Name);

...........
}

Any idea?

Lan


AD Administrator Syncfusion Team February 20, 2007 12:09 AM UTC

Hi Lan,

Instead of using the GetTableCellStyleInfo method, try using the TableModel indexer to get the cell style in a grid. Here is a code snippet.

GridTableControl tc = engine.GroupingControl.GetTableControl(table.Name);
///GridTableCellStyleInfo cellStyle = t.GetTableCellStyle(row, column.Name);
//Use the below method..
GridTableCellStyleInfo cellStyle = t.TableModel[RowIndex,ColIndex] ;

Please refer to the attached sample for more information.
GGC_SummaryRowExportModified.zip

Best regards,
Haneef


AD Administrator Syncfusion Team February 20, 2007 02:50 PM UTC

Hi,
Thanks for help.
It works for me now.

Lan

Loader.
Live Chat Icon For mobile
Up arrow icon