This is a migrated thread and some comments may be shown as answers.

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

5 Answers 97 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alessio
Top achievements
Rank 1
Alessio asked on 06 Feb 2017, 03:15 PM

 

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 ? 

5 Answers, 1 is accepted

Sort by
0
Dimiter Topalov
Telerik team
answered on 08 Feb 2017, 03:02 PM
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.
0
Alessio
Top achievements
Rank 1
answered on 03 Mar 2017, 12:52 PM

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 .. 

 

0
Alessio
Top achievements
Rank 1
answered on 03 Mar 2017, 01:25 PM
Source code in attach
0
Alessio
Top achievements
Rank 1
answered on 06 Mar 2017, 10:17 AM

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

:D

0
Dimiter Topalov
Telerik team
answered on 07 Mar 2017, 07:46 AM
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.
Tags
Grid
Asked by
Alessio
Top achievements
Rank 1
Answers by
Dimiter Topalov
Telerik team
Alessio
Top achievements
Rank 1
Share this question
or