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

grid.setOptions broke columns editor

7 Answers 718 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kudryk
Top achievements
Rank 1
Kudryk asked on 02 Jun 2015, 01:45 PM

I've set columns editor for the column "itpt_name" but after grid.setOptions it is broken

Here is the example http://dojo.telerik.com/EjIlI

You need to follow these steps to reproduse

1) Open http://dojo.telerik.com/EjIlI

2) Click "Run"

3) Double click in any Cell in column "Партия" (you can see working custom editor with the broken images, it is normal)

4) Set sorting for the column "Партия"

5) Save state using "Save state" button

6) Ctrl+F5

7) Load saved state

8) Double click in any Cell in column "Партия" (custom editor is broken, it is not normal)

 Please advise why custom editor is broken

7 Answers, 1 is accepted

Sort by
0
Kudryk
Top achievements
Rank 1
answered on 03 Jun 2015, 07:39 AM

Here is an example from the Kendo API refference. It doesn`t work also

http://dojo.telerik.com/UsAGi

0
Accepted
Dimo
Telerik team
answered on 04 Jun 2015, 10:15 AM
Hi Kudryk,

Please read the first bullet from big yellow note in the setOptions() documentation and let me know if you have additional questions.

http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#methods-setOptions

Regards,
Dimo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Kudryk
Top achievements
Rank 1
answered on 05 Jun 2015, 08:56 AM

Thank you. I've tried to set editors for the grid columns with restored settings, that was my error.

Here is the working example for others who have the same problem

http://dojo.telerik.com/IBOho

0
Bill
Top achievements
Rank 2
answered on 29 Jan 2016, 01:56 AM

This should be a feature request.  Where can I suggest and vote on this?

getOptions and setOptions should include ALL templates.  I've just turned gray figuring this out and having to set all my view, editor and filterable cell templates.

0
Dimo
Telerik team
answered on 29 Jan 2016, 01:08 PM
Hi Bill,

I am sorry about your negative experience. You can submit your suggestions at

http://kendoui-feedback.telerik.com/

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Frédéric.R
Top achievements
Rank 1
answered on 22 May 2017, 11:49 AM

This code is still working for me.
(merged from different solutions seen in the past) :

function saveGridPersistState(grid) {
    if (grid) {
        var dataSource = grid.dataSource;

        var state = {
            aggregate: dataSource.aggregate(),
            filter: dataSource.filter(),
            group: dataSource.group(),
            page: dataSource.page(),
            pageSize: dataSource.pageSize(),
            sort: dataSource.sort()
        };

        $.sessionStorage.set("GridState" + "-" + grid.element.attr('id'), state);

        if (grid.options.persistSelection)
            $.sessionStorage.set("GridSelected" + "-" + grid.element.attr('id'), grid._selectedIds);
    }
}



function loadGridPersistState(grid) {
    if (grid) {
        var state = $.sessionStorage.get("GridState" + "-" + grid.element.attr('id'));

        if (state) {
            if (state.filter) {
                parseFilterDates(state.filter, grid.dataSource.options.schema.model.fields);
            }
            grid.dataSource.query(state);
            ClearFilterContainer(grid);

            var selected = $.sessionStorage.get("GridSelected" + "-" + grid.element.attr('id'));
            if (grid.options.persistSelection && selected)
                grid._selectedIds = selected;

        }
    }
}



function parseFilterDates(filter, fields) {
    if (filter.filters) {
        for (var i = 0; i < filter.filters.length; i++) {
            parseFilterDates(filter.filters[i], fields);
        }
    }
    else {
        if (fields[filter.field].type === "date") {
            filter.value = kendo.parseDate(filter.value);
        }
    }
}

function ClearFilterContainer(grid) {
    var $grid = grid;

    $grid.thead.find('th').each(function () {
        var cell = $(this);

        var multiCheckNS = '.kendoFilterMultiCheck';

        var filterMenu = cell.data('kendoFilterMultiCheck');

        if (filterMenu) {

            var that = filterMenu;

                if (that.checkSource.options.transport) {
                    that.checkSource.options.transport.read.cache = false;

                    that.checkSource = kendo.data.DataSource.create(that.options.checkSource);
                    that.checkSource.options.forceUnique = false;

                    if (that.checkSource.options.transport)
                        that.checkSource.options.transport.read.cache = false;

                    if (that.popup) {
                        that.popup.destroy();
                        that.popup = null;
                    }

                    if (that.container) {
                        that.container.unbind(multiCheckNS);
                        that.container.empty();
                    }
                }
        }
    });
}

 

$(function () {

    $.alwaysUseJsonInStorage(true);     

});

0
Frédéric.R
Top achievements
Rank 1
answered on 23 May 2017, 11:34 AM

Open : 

http://dojo.telerik.com/@frederic.r/ORaKE/10

Tags
Grid
Asked by
Kudryk
Top achievements
Rank 1
Answers by
Kudryk
Top achievements
Rank 1
Dimo
Telerik team
Bill
Top achievements
Rank 2
Frédéric.R
Top achievements
Rank 1
Share this question
or