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

Inline editing Cancel removes the row

17 Answers 1659 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Just
Top achievements
Rank 1
Just asked on 20 Aug 2012, 06:37 PM
I've a page that has a Kendo grid. The grid has a hyperlink column. On click of hyperlink I show a modal popup that has another kendo grid.

In the second grid (within the popup) I've inline editing enabled.
Two problems:
a.) I have a field defined as editable:false and it still is editable on edit click.
{field:"SettingName", title:"Setting Name", filterable: false, width: 200, editable:false }

b.) MAJOR:: I click "Edit" -> the row becomes editable. And then I hit "Cancel". And the row disappears from the grid!!! This has me confused. What could be happening here? Has anybody else observed it?

Thanks.

17 Answers, 1 is accepted

Sort by
0
tan
Top achievements
Rank 1
answered on 21 Aug 2012, 03:56 AM
hey,i hava the same problem.any body know it ....if you have solution.pls write it here.
0
tan
Top achievements
Rank 1
answered on 22 Aug 2012, 02:18 AM
i solves it by define a property id....so. i was new in kendo and i wasn't notice the id must be given property.
0
Jason
Top achievements
Rank 1
answered on 27 Aug 2012, 06:02 PM
do you have the code you added to the js file to stop the cancel button from removing the row??..


Nevermind.. I figured it out.. ty.. :)
0
JORGE CRISOSTOMO
Top achievements
Rank 1
answered on 28 Aug 2012, 12:15 AM
This happened to me too. I looked up the code and it does a filter after a cancel using uid.
I noticed that my definition for the datasource have a type:

schema: {
                    model: {
                        Id: "Id",

The Id is spelled as capital I then d.

I updated it to:
schema: {
                    model: {
                        id: "Id", 
all small caps and it worked as it should. Check your model definition for case typos.

0
Kristin
Top achievements
Rank 1
answered on 28 Sep 2012, 03:07 PM
I currently have a field called "id" and am still having this issue as well.    Every time I hit 'cancel', it still removes the row and I am stumped as to why it's doing it.  Any thoughts???  Here is my code:

   
$("#tblTrucks").kendoGrid({
    dataSource: {
        data: trucks,
        schema: {
            model: {
                fields: {
                    id: { type: "string", validation: { required: true} },
                    license: { type: "string", validation: { required: true} },
                    truckcoid: { type: "string", validation: { required: true} },
                    truckid: { type: "string", validation: { required: true} },
                    enabled: { type: "boolean" }
 
                }
            }
        }
 
    },
    columns: [
        { field: "id", title: "ID", width: "60px" },
        { field: "license", title: "License", width: "85px" },
        { field: "truckcoid", title: "TruckCoId", width: "90px" },
        { field: "truckid", title: "TruckID", width: "75px" },
        { field: "enabled", title: "Enabled", width: "80px" },
        { command: ["edit", "destroy"], width: "190px" }
    ],
    editable: "inline",
    toolbar: ["create"]
 
});
0
Just
Top achievements
Rank 1
answered on 28 Sep 2012, 07:29 PM
Try putting your Id before the fields declaration. Like this
schema: {
            model: {
                 id: "MyIdField",
fields: {
0
Kristin
Top achievements
Rank 1
answered on 01 Oct 2012, 03:59 PM
This worked!  Thank you so much!
0
s
Top achievements
Rank 1
answered on 20 Mar 2014, 10:23 AM
i also have this problem but your solution doesn't work on me 

<div data-role="grid"<br>                     data-editable="inline"<br>                     data-toolbar='[{name:"create", text:"Add"}]'<br>                     data-columns="[{ field: 'name', title:'Name'},<br>                                     { field: 'url', title:'Url'},<br>                                     {command: ['edit','destroy'], width: '200px'}]"<br>                     data-source="{ schema: {<br>                                            model: {<br>                                                    id:'id',<br>                                                    fields:<br>                                                    {<br>                                                    id: { editable: false},<br>                                                    name: { type: 'string' },<br>                                                    url: { type: 'string' }<br>                                                    }<br>                                                   }<br>                                            }<br>                                  }"<br>                     data-bind=" source :details.links" />
0
CS
Top achievements
Rank 2
answered on 30 Jun 2014, 09:10 AM
I have the same problem with my grid, id is set and everything but the row is removed from the grid. But my custom destroy function is not used for this but the standard one that only removes a row, at least it seems so.
0
CS
Top achievements
Rank 2
answered on 01 Jul 2014, 06:53 AM
I think I found a solution, at least it works for me. I have no idea if that is the intended use, but when you give the model an id with the name of one of your fields properties it seems to work. 
0
Nikolay Rusev
Telerik team
answered on 03 Jul 2014, 06:41 AM
Hello Stefan,

The model `id` is a *must* in order to have state tracking correctly. It is internally used for checking whether the model instance is `new` or `existing`.

Regards,
Nikolay Rusev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
CS
Top achievements
Rank 2
answered on 03 Jul 2014, 09:26 AM
The problem is that the id seems to need to match with one of the field property names in order to work correctly. I assumed I can freely choose a name for the id.
0
Nikolay Rusev
Telerik team
answered on 04 Jul 2014, 08:19 AM
Hello Stefan,

Yes, `id` field must be actual field from the model.

Regards,
Nikolay Rusev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Kenneth
Top achievements
Rank 1
answered on 12 Feb 2015, 02:44 PM
It appears there is a case sensitive issue here.  If I use the following in my datasource (note the captial "I" in Id to make it different from the model id), all is well and the Cancel button just cancels the operation and leaves the row in tact.

schema: {
  model: {
    id: "Id",
    fields: {
      Id: { type: "number", validation: {required: true } },
...

If I instead name my field "id" (lowercase) the Cancel button acts like a delete button and the row is removed:

schema: {
  model: {
    id: "id",
    fields: {
      id: { type: "number", validation: {required: true } },
...

I really didn't expect that "feature".
0
Nikolay Rusev
Telerik team
answered on 13 Feb 2015, 01:47 PM

Hello Kenneth,

 

JavaScript syntax is case sensitive. Word casing does matter and you should be careful when defining fields name.

 

Regards,
Nikolay Rusev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Kenneth
Top achievements
Rank 1
answered on 13 Feb 2015, 02:06 PM
Thank you Nikolay.  Understood.  However, I've seen developers commonly use "id" as a database field name (usually the primary key) on database tables.  I would either add a note to the documentation or throw a configuration error from the control if the field "id" is used since it is a reserved name.
0
Benny
Top achievements
Rank 1
answered on 26 Feb 2015, 01:14 PM
Thanks a lot. It works
Tags
Grid
Asked by
Just
Top achievements
Rank 1
Answers by
tan
Top achievements
Rank 1
Jason
Top achievements
Rank 1
JORGE CRISOSTOMO
Top achievements
Rank 1
Kristin
Top achievements
Rank 1
Just
Top achievements
Rank 1
s
Top achievements
Rank 1
CS
Top achievements
Rank 2
Nikolay Rusev
Telerik team
Kenneth
Top achievements
Rank 1
Benny
Top achievements
Rank 1
Share this question
or