douqingji3026 2014-04-17 05:41
浏览 57

如何设置默认的kendo ui网格索引顺序

I want to set by default index order in ascending,currently it showing random. My demo code is.

<?php
        // For transfer the data from one page to another page
        $transportData = new Transport(false);
        // read($url, $data=null, $type='POST', $dataType='', $contentType='',  $cache=false)
        $transport = $transportData->read($this->Html->url(array('controller'=>'ObjectTypes/lists')), $this->ObjectType->indexFields, 'POST', '', 'application/json');
        $schemaModel = new SchemaModel('ID', false);

        // Format to add field:
        $model = $schemaModel->addSchemaField('Code');
        $model = $schemaModel->addSchemaField('Name');

        $schema = $schemaModel->createSchema($model);  // create schema with data, errors, model, total.

        $gridDataSource = new GridDataSource($schema, $transport, '', false); //($schema, $transport='', $data='', $inline=true)
        $dataSource = $gridDataSource->addProperty('pageSize', 20);
        $dataSource = $gridDataSource->addProperty('serverPaging', true);
        $dataSource = $gridDataSource->addProperty('serverSorting', true);


        $name = new \Kendo\UI\GridColumn();
         $name->field('Name')
              ->headerTemplate('<b>Name</b>')
              ->title('Name');



        // Creating Grid with Sort functionality, Pagination, Filter functionality, Column Reorder functionality, Column Resize functionality, Column Group functionality..

        $kendoGrid = new KendoGrid('ObjectType', $dataSource, '', false);
        $grid = $kendoGrid->get();
        $grid->addColumn($code, $name, $command);

        echo $grid->render();
    ?>
</div>

so please suggest me how to add property into addcolumn to set order.

  • 写回答

1条回答 默认 最新

  • dongsimang4036 2014-07-04 08:41
    关注

    you have to set it on the data source. Not sure, what is the GridDataSource class, but I would suggest calling:

    $gridDataSource->addProperty('sort', '[{"field":"Name","dir":"asc"}]');
    

    or if you are json_encoding values in addProperty method:

    $gridDataSource->addProperty('sort', array('field' => 'Name', 'dir' => 'asc'));
    
    评论

报告相同问题?

悬赏问题

  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算