douxianliu6756 2016-08-28 10:04
浏览 27

Kendo UI PHP - 模板上的过滤器

I am using Kendo UI for PHP - Grid Control to display data. Now my table structure is something like this: It has first_name and last_name but not name. So I do this:

 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;

However, now when I try to do the Filtering, it happens for country, city but not the "name" field. This is my code for creating the table on server side

$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');

This is the error from logs exception 'ErrorException' with message 'PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens' in DataSourceResult.php:540

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 划分vlan后不通了
    • ¥15 GDI处理通道视频时总是带有白色锯齿
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制
    • ¥15 merge函数占用内存过大
    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大