Kendo Mesh Integration with Coldfusion

We want to move from our current grids (JQWidgets) to KendoUI grids, and I'm working on a proof of concept. Our biggest requirement is server-side paging / sorting / filtering and also where I ran into problems.

Our existing grids are XML based, so I created a Kendo grid that does the same:

$(document).ready(function(){
    var xmlDataRemote = new kendo.data.DataSource({
        transport: {
            read: { url: "/KendoDashboard/KendoController.cfc?method=getGrid" }
        }, 
        pageSize: 20, 
        serverPaging: true, 
        serverSorting: true,
        serverFiltering: true,
        schema: {
            type: "xml",
            data: "/Items/Item",
            total: "/Items/Item/TotalRows",
            model: {
                id: "ID",
                fields: {
                    Name: { field: "Name/text()", type: "string" },
                    Status: { field: "Status/text()", type: "string" },
                    Type: { field: "Type/text()", type: "string" }
                }
            }
        }
    });

    var grid = $("#grid").kendoGrid({
        dataSource: xmlDataRemote,
        pageable: true,
        sortable: true, 
        filterable: true,
        columns: [
            { title: "Name", field: "Name" },
            { title: "Status", field: "Status" },
            { title: "Type", field: "Type" }    
        ]
    });
});

      

XML example:

<Items>           
    <Item>
        <ID>1</ID>
        <Name>First Item Name</Name>
        <Status>Active</Status>
        <Type>Online</Type>   
    </Item>           
    <Item>
        <ID>2</ID>
        <Name>Second Item Name</Name>
        <Status>Inactive</Status>
        <Type>External</Type>
    </Item>
    <TotalRows>22</TotalRows>
</Items>

      

My paging problem: The total given in the datasource doesn't seem to work. The grid footer has "No items to display" instead of "1-20 of 22 items" and no paging options. I'm also not sure what the "take" and "pass" parameters are passed from the grid (see below).

My sort / filtering problem: The sorting and filtering options passed in are some formatted strings:

/KendoDashboard/KendoController.cfc?method=getCoursesGrid&take=20&skip=0&page=1&pageSize=20&sort%5B0%5D%5Bfield%5D=Name&sort%5B0%5D%5Bdir%5D=desc&filter%5Blogic%5D=and&filter%5Bfilters%5D%5B0%5D%5Bfield%5D=Name&filter%5Bfilters%5D%5B0%5D%5Boperator%5D=eq&filter%5Bfilters%5D%5B0%5D%5Bvalue%5D=test

      

If I look at it in Firebug, the parameters are listed as:

filter[filters][0][field]   Name
filter[filters][0][operator]    eq
filter[filters][0][value]   test
filter[logic]   and
method  getCoursesGrid
page    1
pageSize    20
skip    0
sort[0][dir]    desc
sort[0][field]  Name
take    20

      

Setting up a cfargument named "filter" and a string type and then resetting it just returns zero (0). And of course Coldfusion won't use the "filter [filters]" name argument, so I'll be at a loss for how to proceed.

+3


source to share


1 answer


You can set the total as

total: function(response) {
  return response.Items.TotalRows;
}

      



And look in the variable response

if something is wrong.

0


source







All Articles