Kendo DataSource: How to define “Computed” Properties for data read from remote odata source

前端 未结 3 1056
自闭症患者
自闭症患者 2021-01-15 06:11

Situation:

  • kendo DataSource

    var ordersDataSource = new kendo.data.DataSource({
        type: \"odata\",
        transport: {
            read: {
                    
    
    
            
3条回答
  •  没有蜡笔的小新
    2021-01-15 06:33

    Below an example to use it in a grid. It can then also sort the column.

    $("#grid").kendoGrid({ 
        dataSource: {
            data: [
                { first: "John", last: "Doe" }, 
                { first: "Jane", last: "Doe" }
            ],
            schema: {
              model: {
                // Calculated field
                fullName: function() {
                  return this.first + " " + this.last;
                },
                fields: {
                   first: { type: "string" },
                   last: { type: "string" }
                }
              }
            }
        },
        columns: [
            {
                // Trigger function of the Calculated field
                field: "fullName()",
                title: "Fullname"
            },
            {
                field: "first",
                title: "firstname"
            }
        ]
    });
    

提交回复
热议问题