Setting column defenitions within a datasource read

4 posts, 0 answers
  1. Danny
    Danny avatar
    29 posts
    Member since:
    Feb 2012

    Posted 21 Aug 2014 Link to this post

    Hi, 

    Is there a way to set the column definitions of a grid within its datasource read-function?

    We need to retrieve the data from the server and want to use server-side paging, hereby the column-definitions come directly from the server and are not known before the datasource read is called and can not be defined on the grid directly when initializing it.

    I have made an example  to illustrate the porblem.

    http://dojo.telerik.com/IWiqo/7
  2. DavidOBrien
    DavidOBrien avatar
    14 posts
    Member since:
    Sep 2012

    Posted 21 Aug 2014 in reply to Danny Link to this post

    What kind of page is it? .net , php , jsp? plain html?

    On most of my more complex pages I have a database table with the column definitions in it already and read them when the page generates for both the schema definition and grid columns definition

    schema: {
                                data: "data",
                                total: "total",
                                model: {
                                    id: "EmailID",
                                    fields: {
    <?php
      foreach ( $columns as $key => $value ) {
       echo str_repeat("\t",8) . $value['field'] . ': { editable: ' . $value['editable'] . ', type: "' . $value['type'] . '"},'."\n";
      }
    ?>
                                    }
                                }
                            }

    $("#grid").kendoGrid({
                            dataSource: dataSource,
                            pageable: true,
                            toolbar: ["create","save","cancel"],
                            columns: [
                                { command: ["edit", "destroy"], title: " ", width: 190 },
    <?php
       foreach ( $columns as $key => $value ) {
         echo str_repeat("\t",7) . "{" .
         ( !
    empty( $value['field'] ) ? "field:'" . $value['field'] . "'," : '' ) .
         ( !
    empty( $value['title'] ) ? "title:\"" . $value['title'] . "\"," : '' ) .
         ( !
    empty( $value['width'] ) ? "width:" . $value['width'] . "," : '' ) .
         ( !
    empty( $value['template'] ) ? "template:'" . $value['template'] . "'," : '' ) .
         ( !
    empty( $value['headerTemplate'] ) ? "headerTemplate:\"" . $value['headerTemplate'] . "\"," : '' ) .
         ( !
    empty( $value['editor'] ) ? "editor:" . $value['editor'] . ","    : '' ) . "},\n";
       }
    ?>
                            ],
                            editable: {
                                mode: "popup",
                            },
                            sortable: true,                       
                        });

  3. Kendo UI is VS 2017 Ready
  4. Danny
    Danny avatar
    29 posts
    Member since:
    Feb 2012

    Posted 22 Aug 2014 in reply to DavidOBrien Link to this post

    It is an .Net page. 

    We receive the column-definitions together with the data that we need to show. In your solution we need to do two calls to the server. one to retrieve the column-definitions and a second one to receive the actual data. This is not desirable within our application.


  5. Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 22 Aug 2014 Link to this post

    Hi Danny,

    The described combination of requirements is unfortunately not supported.

    If you sacrifice one of the requirements below, then the scenario becomes possible to implement.

    - single request, which includes both configuration settings and data
    - server data operations (paging, sorting, filtering, editing)
    - usage of non-string data fields for data operations

    Regards,
    Dimo
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready