This is a migrated thread and some comments may be shown as answers.

"Read" function for MVC PivotGrid?

3 Answers 322 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Tom
Top achievements
Rank 1
Iron
Tom asked on 18 Apr 2017, 10:04 AM

I have a number of regular MVC grids that make their requests to controllers with additional data, and they make use of the Data attribute to call a function which returns an object. For example:

@(Html.Kendo().Grid<Model>()
                .Name("Grid")
                .DataSource(dataSource => dataSource
                    .Ajax()
                    .ServerOperation(true)
                    .Read(read => read
                        .Action("ActionName", "ControllerName")
                        .Data("FunctionName")
                    )
                )

...and this works fine, but for the PivotGrid I can't seem to find a matching equivalent. The configuration seems to be quite different in fact:

@(Html.Kendo().PivotGrid<Model>()
                .Name("pivotGrid")
                .DataSource(dataSource => dataSource
                    .Ajax()
                    .Transport(transport => transport
                        .Read("Action", "Controller")
                    )
                    .Events(ev => ev.RequestEnd("onRequestEnd").RequestStart("onRequestStart"))

I cannot seem to use the same configuration (Transport instead of Read), and I cannot find anywhere the "Data" action can be assigned. I can set this attribute to the relevant javascript function after page load using:

$("#pivotGrid").data('kendoPivotGrid').dataSource.transport.options.read.data = pivotSync;

...but I would like to be able to set this during the initial configuration of the pivot grid. Is this possible?

3 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 20 Apr 2017, 10:48 AM

Hello,

The Data method should work as expected since the PivotDataSource does inherit from the DataSource object, which provides the data function. 

Actually I did modify the DataSource configuration for our PivotGrid / Remote binding demo as shown below: 

.DataSource(dataSource => dataSource
        .Ajax()
        .Transport(transport => transport.Read(read => read.Action("Customers_Read", "PivotGrid").Data("test")))
<script>
    function test() {
        return {
            test: "test"
        }
    }
</script>

and it worked fine. The test: test was sent along with the request to the server. 

Regards,
Boyan Dimitrov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Tom
Top achievements
Rank 1
Iron
answered on 24 Apr 2017, 08:14 AM

I have tried this, and get the following error:

 

Compiler Error Message: CS1061: 'PivotAjaxDataSourceTransportBuilder' does not contain a definition for 'Data' and no extension method 'Data' accepting a first argument of type 'PivotAjaxDataSourceTransportBuilder' could be found (are you missing a using directive or an assembly reference?)

0
Tom
Top achievements
Rank 1
Iron
answered on 24 Apr 2017, 08:16 AM
Ah, minor typo on my part, this is now working, thanks.
Tags
PivotGrid
Asked by
Tom
Top achievements
Rank 1
Iron
Answers by
Boyan Dimitrov
Telerik team
Tom
Top achievements
Rank 1
Iron
Share this question
or