API
Version 7.x > API > Unigrid Advanced Export View modes: 
User avatar
Certified Developer 10
Certified Developer 10
josha-bpstudios - 10/24/2013 1:03:53 PM
   
Unigrid Advanced Export
I have a unigrid on a site that takes data from a registration process from an event and adds in fields that correlate to the event that was signed up for. Basically events have different options, so it changes based on the event and what the user chose when they registered. For some reason I cannot get the advanced export to work. It worked in version 6, but in version 7 something seems to be stomping the functionality. I am only given the option to export one column. I am stepping through the code and it seems that only one gets brought in from the UnigridExportHelper.Boundfields. Does any one know of a specific method that would need to be called to set the columns for the unigrid export helper? We are doing custom on_rowdatabound and on_externaldatabound events, but I can't see how this would affect the export, as the data all comes in correctly in the unigrid itself.

If you have any ideas, I am open to suggestions or possible fixes.

Thanks,
Josh

User avatar
Certified Developer 10
Certified Developer 10
josha-bpstudios - 10/24/2013 2:43:09 PM
   
RE:Unigrid Advanced Export
Update: I have found that the reason is that in the xml file, the columns aren't specified, but still I am not sure why my code isn't accomplishing this. If I put in a column attribute in the xml file and then do the export, I get the option to export that field. Was the advanced export not designed to handle columns created through code, or are columns not supposed to be added during the unigrid event _onloadcolumns?

User avatar
Kentico MVP
Kentico MVP
Brenden Kehren - 10/25/2013 8:23:08 AM
   
RE:Unigrid Advanced Export
Do you have an update panel around the webpart? I've found this was an issue for me.

User avatar
Kentico MVP
Kentico MVP
Brenden Kehren - 10/25/2013 8:22:15 AM
   
RE:Unigrid Advanced Export
Have you thought about not even using the built-in functionality and creating it yourself? here's an example of 2 button click events and exporting to csv or xml in a webpart I created.
protected void btnExportCsv_Click(object sender, EventArgs e)
{
ExportData(DataExportFormatEnum.CSV);
}

protected void btnExportXml_Click(object sender, EventArgs e)
{
ExportData(DataExportFormatEnum.XML);
}

private void ExportData(DataExportFormatEnum format)
{
DataSet ds = MyProvider.GetAllTransactions(StartDate, EndDate).DataSetResults;
DataExportHelper eh = new DataExportHelper(ds);
eh.ExportData(format, Page.Response);
}

User avatar
Certified Developer 10
Certified Developer 10
josha-bpstudios - 10/25/2013 8:30:07 AM
   
RE:Unigrid Advanced Export
Thanks Froggeye...I actually have already done that, but people prefer to be able to pick the columns and have more control. I have found the issue....

The method Unigrid.AddColumn does not add a column as you would think it would.

You have to instantiate the CMS.UIControls.UniGridConfig.Column during the onloadcolumns event and call the method UniGrid.GridColumns.Columns.Add(column) and add it that way, otherwise it won't register your column for the export.

I appreciate the help, and hopefully if you ever run into this problem, this will help.