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

Exporting ComboBox lookup column Group text

Hi,
V4.4.0.51 VS2003

In my attched sample project, I have two ways to setup a lookup column:
1. Set lookup by ComboBox list
2. Set Lookup by FK Relateship

But I insist to use the "1. Set lookup by ComboBox list" method because I got a application has been developed in this way.

In the sample project, The GGC group has a combobox lookup column "Country Name" which displays full name Description of a country code.

Please group by the 'County', then click 'Export to Excel' button, it exports three chars of the country CODE. I want to export the country DESCRIPTION. How can I do it?

Another problem is the group sorting. when it is group by country, the group is not sorted by the DESCRIPTION. it is sorted by the group's category which is the country's CODE.

Thanks in advance.


Lan






GGC_SummaryRowExport_2605fc150.zip

6 Replies

AD Administrator Syncfusion Team February 19, 2007 08:55 PM UTC

Hi Lan,

Issue 1 : Export

I have modified the ExportCaption method in GroupingGridExcelConverterExt.cs file. Please try the attached sample and let me know if this helps.
Sample : GGC_SummaryRowExportModified.zip

Issue 2: Sort

You need to implement a custom sorting to do this. You can add a custom IComparer to the SortColumnDescriptor for this column. You do this by setting the Comparer property on the SortColumnDescriptor. In your custom IComparer object, you can sort based on any criteria of your choice.

Please refer these forum threads
http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=35370
http://www.syncfusion.com/support/Forums/message.aspx?MessageID=46737

When you do custom sorting in the grid, then you need to use custom grouping for handling the groups. See the following KB article for more details on this.
http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=147

Best Regards,
Haneef


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

Hi,
Thanks for help.

Now Exporting the group description works.

I also figured out for the customized group sorting based on your reference links.

Now I got another issue:
The 'country' is combobox lookup column, It works ok to export DESCRIPTION when the grid has no grouping. but if you group the grid by State or population, it will export the country CODE instead of DESCRIPTION. any idea?

Lan



AD Administrator Syncfusion Team February 20, 2007 03:08 PM UTC

Hi,
Another question.
if you set ShowCaption=false in TopLevelGroupOptions, then export the grid to excel. It will export the first column Headertext 'Identity' in the first row of excel sheet, instead of the 'My Table 17 Items'.

if I don't want to show this line in excel at all, how can I do it?

Lan



AD Administrator Syncfusion Team February 20, 2007 09:20 PM UTC

Hi Lan,

Issue 1:

The 'country' is combobox lookup column, It works ok to export DESCRIPTION when the grid has no grouping. but if you group the grid by State or population, it will export the country CODE instead of DESCRIPTION. any idea?
>>>>>>>

The grouping grid currently has no built-in support for this. Sorry for the inconvenience, but there is no easy way to get this working.

Issue 2:

if you set ShowCaption=false in TopLevelGroupOptions, then export the grid to excel. It will export the first column Headertext 'Identity' in the first row of excel sheet, instead of the 'My Table 17 Items'.
>>>>>
Try checking the ShowCaption property for the TopLevelGroup in a ExportCaption method. Here is a code snippet.

private int ExportCaption( GridCaptionRow captionRow, IWorksheet sheet, int index,
ConverterOptions options, int iCurrentGroupLevel, Stack stackStartIndexes, ref int iCurrentLevel)
{
if( captionRow == null )
throw new ArgumentNullException( "captionRow" );
if( sheet == null )
throw new ArgumentNullException( "sheet" );
if( index < 0 )
throw new ArgumentOutOfRangeException( "index", index, "Value can not be less 0" );
GridTableDescriptor table = ( GridTableDescriptor )captionRow.ParentTableDescriptor;
if( table.Engine.GroupingControl.TopLevelGroupOptions.ShowCaption || captionRow.ParentGroup.IsTopLevelGroup )
{
///code to export the caption row to excel.
}
}

Best regards,
Haneef


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

Hi,
Thank you for help.

I've figured out how to make Issue 1 work.
Please see my attached sample. I modified following two things:

// 1. add this line before GroupingGridToExcel
this.gridGroupingControl1.Table.ExpandAllGroups();
converter.GroupingGridToExcel(this.gridGroupingControl1, saveFileDialog.FileName,
Syncfusion.GridExcelConverter.ConverterOptions.Default);


//2. modify 'ExportRecordRow' in GroupingGridExcelConverterExt.cs
private int ExportRecordRow( RecordRow row, IWorksheet sheet, int index, ConverterOptions options
, int iIndexInGroup, int iGroupLevel, out int iSkipRecordRows )
{
..... //lan: is combobox
bool bIsComboBox=(table.Columns[strColumnName].Appearance.AnyRecordFieldCell.CellType =="ComboBox");

.....
//if(cellStyle.CellType == "ComboBox")
if (bIsComboBox)
{
//range.Value2 = cellStyle.FormattedText;
//Lan: To display combobox lookup desc,
//must use the visiblecolumn index because when it is grouped, col index changed
ColIndex = table.VisibleColumns.IndexOf( strColumnName );
ColIndex = table.FieldToColIndex( ColIndex );


range.Value2 = t.TableModel[RowIndex,ColIndex].FormattedText;


}
else
{
object value = row.ParentRecord.GetValue( field );
range.Value2 = ( value == null ) ? string.Empty : value;
}
CopyStyle( cellStyle, range );
.....
}


regards,

Lan


GGC_SummaryRowExportModified.zip


AD Administrator Syncfusion Team February 22, 2007 09:13 PM UTC

Hi Lan,

Glad that you have solved your issue. Please feel free to open a new forum if you have more questions.

Thanks for your continued interest in Syncfusion Products.

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon