"Read" function for MVC PivotGrid?

4 posts, 0 answers
  1. Tom
    Tom avatar
    18 posts
    Member since:
    Apr 2016

    Posted 18 Apr Link to this post

    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?

  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1966 posts

    Posted 20 Apr Link to this post

    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.
  3. Tom
    Tom avatar
    18 posts
    Member since:
    Apr 2016

    Posted 24 Apr in reply to Boyan Dimitrov Link to this post

    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?)

  4. Tom
    Tom avatar
    18 posts
    Member since:
    Apr 2016

    Posted 24 Apr in reply to Tom Link to this post

    Ah, minor typo on my part, this is now working, thanks.
Back to Top