0
votes

I have a radgrid that contains a mastertableview. On top of the mastertableview there is a form to user to search for data results which is used as data source to bind the mastertableview.

When user clicks the search button in the form, a javascript function is invoked to call a web service method to get the result data set. But somehow my web service method only returns current page's amount of data. Meanwhile, no matter which items are selected in the mastertableview by the user, the exporting buttons only export the same set of data.

Because all the data is bounded using javascript in the client side but my exporting code is c#, I am looking for a way to export the items selected by the user or if no items are selected just exporting all the data instead of the data residing in the current page.

Thanks in advance.

2

2 Answers

0
votes

This usually happens when using simple data-binding. You have to use advanced data-binding (or a datasource control) in order for this functionality to work properly:

Please note also that to use the export functionality your grid must be configured to use advanced databinding in contrast with the simple databind which does not support exporting.

0
votes

You seem to have 2 different problems here, I agree with what the previous person said in that you should be looking at advanced databinding (See http://demos.telerik.com/aspnet-ajax/grid/examples/programming/needdatasource/defaultcs.aspx). I've never personally had the problem that it was only searching the currently visible results, but I perform a "Rebind" when the search button is pressed.

In regards to the exporting I use the following code behind an "Export to Excel" button and it has meant all my data is exported regardless of whether it's on the currently visible page or not.

    grid.ExportSettings.IgnorePaging = True;
    grid.ExportSettings.OpenInNewWindow = True;
    grid.ExportSettings.FileName = String.Format("{0} {1:yyyy-MM-dd HHmm}",requiredFilename , Now);
    grid.MasterTableView.ExportToExcel();

You could probably add similar code to the OnGridExporting event (minus the .ExportToExcel bit of course!) to ensure that the exported document contains all data regardless of what is currently visible