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

Removed rows reappear

1 Answer 155 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 01 Feb 2013, 12:34 AM
I'm moving data between two different Kendo grids, removing items from one and adding them to another. I'm not going by the 'delete' command for removing them. I've noticed a bug where one of the grids has dataItems reappear in the view after triggering a filter, page, sort etc. action. This gird is created with locally bound data, via the data property of the datasource, so it has a copy of the 'pristine' data floating. I had to resort to the following to get them to be permanently removed.
var rows = chooseGrid.select(),
    dataItems = [];
 
for (var i = rows.length; i--;) {
    dataItems.unshift(chooseGrid.dataItem(rows[i]));
    chooseGrid.dataSource.remove(dataItems[0]);
    koqGrid.dataSource.insert(AdminToProfileKoQ(dataItems[0]));
    addedQuestions.unshift(dataItems[0]);
     
    for(var j = chooseGrid.dataSource.options.data.length; j--; )
    {
        if(chooseGrid.dataSource.options.data[j].Id == dataItems[0].Id) {
            chooseGrid.dataSource.options.data.splice(j, 1);
            break;
        }
    }
};
If I don't whack the removed entries from the dataSource.options.data copy, they reappear.

I haven't gotten to the point where I'm adding items back the other way, but I'm half anticipating a similar problem. Is there a solution for this? Some method to save or sync the data source?

Here's the rest of the grid declaration - I realize I could probably turn it back into a properly wrapped MVC helper extension, but I've grown to like the greater control provided by the straight JS initialization.
$("#ChooseKnockOutQuestionGrid").kendoGrid({
    dataSource: {
        schema : {
            model: {
                fields: {
                    Id: { type: "number" },
                    AdminLeadType: { type: "number" },
                    Answer1Text: { type: "string" },
                    Answer2Text: { type: "string" },
                    Enabled: { type: "boolean" },
                    QuestionText: { type: "string" },
                    QuestionTypeId : {type: "number"},
                    Price: { type: "number" }
                }
            }
        },
        data : @Html.Raw(ViewBag.Data),
        pageSize: 5,
        serverFiltering: false,
        serverGrouping: false,
        serverSorting: false,
        serverPaging: false
    },
    filterable: true,
    sortable: true,
    selectable: "multiple, row",
    columns: [{
            field:"QuestionText",
            title:"Question Text"
        },
        "Price"],
    dataBound: OnChooseDataBound,
    change: OnChooseChange
});

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 04 Feb 2013, 02:46 PM
Hello Eric,

I am not able to reproduce such behavior. Could you please apply your approach to this JsBin demo so I can investigate the case?
I can see in the current example that after removing an item and then sorting, the item does not appear back.

http://jsbin.com/edamuj/77/edit

Kind Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Eric
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or