Kendo UI PHP - 模板上的过滤器

时间:2016-08-28 10:04:43

标签: javascript php jquery kendo-ui kendo-grid

我正在使用Kendo UI for PHP - Grid Control来显示数据。 现在我的表结构是这样的:它有first_name和last_name但不是name。 所以我这样做:

 header('Content-Type: application/json');
        $request = json_decode(file_get_contents('php://input'));   

        echo json_encode($this->result->read('users', array('CONCAT(first_name, \' \', last_name) as name','first_name','last_name', 'country', 'status', 'city','role_id'), $request));
        exit;

然而,现在当我尝试进行过滤时,它发生在国家,城市,而不是"名称"领域。这是我在服务器端创建表的代码

$contactNameField = new \Kendo\Data\DataSourceSchemaModelField('name');
        $contactNameField->type('string');

        $firstNameField = new \Kendo\Data\DataSourceSchemaModelField('first_name');
        $firstNameField->type('string');

        $lastNameField = new \Kendo\Data\DataSourceSchemaModelField('last_name');
        $lastNameField->type('string');

        $contactCountryField = new \Kendo\Data\DataSourceSchemaModelField('country');
        $contactCountryField->type('string');

        $statusField = new \Kendo\Data\DataSourceSchemaModelField('status');
        $statusField->type('string');

        $cityField = new \Kendo\Data\DataSourceSchemaModelField('city');
        $cityField->type('string');
        $model->addField($contactNameField)
            ->addField($contactCountryField)
            ->addField($statusField)
            ->addField($firstNameField)
            ->addField($lastNameField)
            ->addField($cityField);

 $schema = new \Kendo\Data\DataSourceSchema();
        $schema->data('data')
            ->errors('errors')
            ->groups('groups')
            ->model($model)
            ->total('total');
        $dataSource = new \Kendo\Data\DataSource();

        $dataSource->transport($transport)
            ->pageSize(10)
            ->serverPaging(true)
            ->serverSorting(true)
            ->serverGrouping(true)
            ->serverFiltering(true)
            ->schema($schema);

        $gridFilterable = new \Kendo\UI\GridFilterable();
        $gridFilterable->mode("row");
 $contactName = new \Kendo\UI\GridColumn();
        $contactName->field('name')

            ->title('Name')
            ->filterable(true)
            ->sortable(true)
            ->width(240);

 $status = new \Kendo\UI\GridColumn();
        $status->field('status')
            ->title('status');

        $city = new \Kendo\UI\GridColumn();
        $city->field('city')
            ->width(150);

$grid->addColumn($contactName, $country , $status, $city)          
            ->dataSource($dataSource)
            ->toolbarTemplateId('toolbar')
            ->sortable(true)
            ->filterable($gridFilterable)
            ->groupable(true)
            ->pageable($pageable)
            ->attr('style', 'height:550px');

这是日志中的错误 异常' ErrorException' with message' PDOStatement :: execute():SQLSTATE [HY093]:参数号无效:绑定变量数与令牌数不匹配'在DataSourceResult.php:540

0 个答案:

没有答案