New to Kendo UI

Posted by goo on 22-Mar-2019 21:50

11.7.4

I have been playing around with a Kendo GRID for some hours and starting to get kind of understanding, however, I wonder how to transfer filter data using datasource.read. I found transport.parameterMap, but I am not sure if that is the right way to do it. 

I want i.e. one input field searchPhrase, and a button bthSearchPrhase. I have the onClick and I am able to send the stuff using query_string. Eariler I used field_map instead, but I am kind of not sure what to use. 

What are you doing?

Posted by goo on 23-Mar-2019 07:58

After a bit sleep, I suddenly found out :-)

When doing read (GET), I get the data from query_string (Webspeed), and when doing POST I will check web-context:form-input.

Posted by goo on 24-Mar-2019 14:06

Then suddenly I got it to work!!!! enought hours, and we will find out. Not that clear in the kendo documentation.

var dsCustomers = new kendo.data.DataSource({

   requestStart: function(ev) {

   onRequestStart(ev)

 },

 transport: {

     read: {

       url: "localhost/.../customerkendo.r",

    contentType: "application/json",

    dataType: "json"

   }, //Read

     parameterMap: function(data,type){

       return $.extend({searchPhrase: $("#searchPhrase").val()},data);

     }

   }, //transport

   schema: {

   type: "json",

   data: "Customer",             <-------------------------- what to use in the Json data

     model: {

      fields: {

        CustNum: {field: "CustNum", type:"number"},

        Name: {field: "Name", type:"string"},

        RowCount: {field: "RowCount", type:"number"},

         RowIdent1: {field: "RowIdent1", type:"string"}

      } //fields

     } //Model

   }, //Schema

serverPaging: true,

pageSize: 5

 }); /*dsCustomers*/

$("#grid").kendoGrid({

 columns: [

             {title: "CustNum", field: "CustNum",

        sortable: {

        initialDirection: "desc"

 },

 type: "number",

},

            {title: "Name", field: "Name", type: "string"},

    {title: "RowId", field: "RowIdent1", hidden: true},

],

 columnResizeHandleWidth: 10,

   dataSource: dsCustomers,         <------------------- Points to the datasource

 height: 400,

 resizable: true,

 sortable: true,

 selectable: "row",

 filterable: true //Test

 });

Sendt from webspeed:

{"Customer":[{"CustNum":7,"Name":"Aerobics valine Ky","RowIdent1":"0x0000000000000067","RowCount":113},{"CustNum":18,"Name":"Antin Metsastysase","RowIdent1":"0x0000000000000072","RowCount":112}]

All Replies

Posted by goo on 23-Mar-2019 07:58

After a bit sleep, I suddenly found out :-)

When doing read (GET), I get the data from query_string (Webspeed), and when doing POST I will check web-context:form-input.

Posted by goo on 23-Mar-2019 16:30

I am able to populate a Kendo grid, but need som extra data. I think the best solution will be to add one extra json object to the result, but that breaks the grid data. How can I tell the datasource to use one specific object, if more than one json object in the result?

Posted by goo on 24-Mar-2019 14:06

Then suddenly I got it to work!!!! enought hours, and we will find out. Not that clear in the kendo documentation.

var dsCustomers = new kendo.data.DataSource({

   requestStart: function(ev) {

   onRequestStart(ev)

 },

 transport: {

     read: {

       url: "localhost/.../customerkendo.r",

    contentType: "application/json",

    dataType: "json"

   }, //Read

     parameterMap: function(data,type){

       return $.extend({searchPhrase: $("#searchPhrase").val()},data);

     }

   }, //transport

   schema: {

   type: "json",

   data: "Customer",             <-------------------------- what to use in the Json data

     model: {

      fields: {

        CustNum: {field: "CustNum", type:"number"},

        Name: {field: "Name", type:"string"},

        RowCount: {field: "RowCount", type:"number"},

         RowIdent1: {field: "RowIdent1", type:"string"}

      } //fields

     } //Model

   }, //Schema

serverPaging: true,

pageSize: 5

 }); /*dsCustomers*/

$("#grid").kendoGrid({

 columns: [

             {title: "CustNum", field: "CustNum",

        sortable: {

        initialDirection: "desc"

 },

 type: "number",

},

            {title: "Name", field: "Name", type: "string"},

    {title: "RowId", field: "RowIdent1", hidden: true},

],

 columnResizeHandleWidth: 10,

   dataSource: dsCustomers,         <------------------- Points to the datasource

 height: 400,

 resizable: true,

 sortable: true,

 selectable: "row",

 filterable: true //Test

 });

Sendt from webspeed:

{"Customer":[{"CustNum":7,"Name":"Aerobics valine Ky","RowIdent1":"0x0000000000000067","RowCount":113},{"CustNum":18,"Name":"Antin Metsastysase","RowIdent1":"0x0000000000000072","RowCount":112}]

This thread is closed