Field on main grid ->> decoded with lazy load table on listbox, can't be filtered or sorted

6 posts, 0 answers
  1. Alessio
    Alessio avatar
    9 posts
    Member since:
    Aug 2016

    Posted 06 Feb Link to this post

     

    As on title , i have an example  grid from a mysql table, one of field was a online field, he take ( s=online or n=online)

    inside  a method post if -->

    if ($_SERVER['REQUEST_METHOD'] == 'POST') {

    i put this -->

            // DECODE TABLE FOR ( Online/Offline ) 
            case 'online':
                $result = $result->read('categories', $decode, $filterForOnline);
                break;

    and after this -->

        if ($type != 'online') {
            $online = new DataSourceResult('mysql:host=localhost;dbname=<dbname>,<user>,<password>, $options);
            $online = $online->read('categories', $decode);
            $data = &$result['data'];

            for ($index = 0, $count = count($data); $index < $count; $index++) {
                if ($type == "create") {
                    $onlineCode = $data[$index]->online;
                } else {
                    $onlineCode = $data[$index]['online'];
                }
                foreach ($online['data'] as $status) {
                    if ($status['code'] == $onlineCode) {
                        if ($type == "create") {
                            $data[$index]->Status = $status;
                        } else {
                            $data[$index]['Status'] = $status;
                        }
                        break;
                    }
                }
            }
        }

    the definition of colum is this -->

    $category = new \Kendo\UI\GridColumn();
    $category->field('Status')
             ->title('Status')
             ->template('#=Status.description#')
             ->editor('onlineDropDownEditor')

           ->width(180);

    and the add to the grid -->

    $grid->addColumn($phonenumber, $category, $idmessage, $textdata, $imagedata, $orderDate, $command)
           .....

           .....

          ->sortable(true)
         ->filterable(true)

           .....

    the editor -->

    function onlineDropDownEditor(container, options) {
        $('<input data-text-field="description" data-value-field="code" data-bind="value:' + options.field + '"/>')
            .appendTo(container)
            .kendoDropDownList({
                autoBind: false,
                dataSource: {
                    schema: {
                        data: "data"
                    },
                    transport: {
                        read: {
                            url: "myurl.php?type=online",
                            type: "POST",
                            dataType: "json"
                        }
                    }
                }
            });
        }
    </script>

     

    it's all working, decode, save data etc etc, 

    just one think not working on that field, filtering and sorting .. how i can modify the code for have this ? 

  2. Dimiter Topalov
    Admin
    Dimiter Topalov avatar
    578 posts

    Posted 08 Feb Link to this post

    Hello Alessio,

    If I understand correctly, you are trying to sort and filter the Grid by a column that is a complex object. This is not supported out-of-the-box, as special custom criteria for comparing objects should be provided.

    You can configure the custom sort comparing criteria for the given column via the columns.sortable.compare configuration option, e.g. sorting by the Category column:

    http://dojo.telerik.com/afunOc

    The custom filtering can be performed server-side (or by providing a custom function to the transport.read option), e.g.:

    http://dojo.telerik.com/afunOc/2

    Further information about configuring a custom transport can be found in the following section of our documentation:

    http://docs.telerik.com/kendo-ui/framework/datasource/crud#local-or-custom-transport-crud-operations

    I hope this helps, but if I am missing something, please describe the scenario, and the desired functionality in further details, and send us a similar isolated runnable project, where the problem can be observed, so I can try providing a more-to-the-point suggestion, if one is available. Thank you in advance.

    Regards,
    Dimiter Topalov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Alessio
    Alessio avatar
    9 posts
    Member since:
    Aug 2016

    Posted 03 Mar in reply to Dimiter Topalov Link to this post

    Hello Dimiter, i make something like this 

     

    $sortable = new \Kendo\UI\GridColumnSortable();
    $sortable->initialDirection('asc');
    $sortable->compare(new \Kendo\JavaScriptFunction('function(a, b) { alert("test"); return a.Status.description - b.Status.description; }'));

    $category = new \Kendo\UI\GridColumn();
    $category->field('Status')
             ->title('Status')
             ->template('#=Status.description#')
             ->editor('onlineDropDownEditor')
             ->sortable($sortable)
             ->width(180);

    but is not working .. 

     

  4. Alessio
    Alessio avatar
    9 posts
    Member since:
    Aug 2016

    Posted 03 Mar in reply to Alessio Link to this post

    Source code in attach
  5. Alessio
    Alessio avatar
    9 posts
    Member since:
    Aug 2016

    Posted 06 Mar in reply to Alessio Link to this post

    Resolved, is not a numeric field, but a string one

    :D

  6. Dimiter Topalov
    Admin
    Dimiter Topalov avatar
    578 posts

    Posted 07 Mar Link to this post

    Hi Alessio,

    I am glad you have resolved the issue.

    Do not hesitate to contact us again, if you have any other Kendo UI-related questions or issues.

    Regards,
    Dimiter Topalov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top