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

Select element in editor template doesn't trigger update event when selected items change

2 Answers 212 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mathieu Lafontaine
Top achievements
Rank 1
Mathieu Lafontaine asked on 16 Jan 2013, 08:15 PM
The editor for the RoleIds property shows the correct selections when the row enters the "edit" mode.  However, if I change the selected value in this control and press the update button, no call to my update url is made, as if nothing changed.

What am I missing?

Here's the code (see attached image for behavior):

<div id="myGrid"></div>
<script type="text/javascript">
    $(function () {
        var dataSource = new kendo.data.DataSource({
            transport: {
                read: { url: "/Test/TestRead"},
                update: {
                    url: "/Test/TestUpdate",
                    type: "POST"
                }
            },
            schema: {
                model: {
                    id: "Id"
                }
            }
        });

        $('#myGrid').kendoGrid({
            columns:
                [
                    {command:
                        [{
                                name:"edit",
                                buttonType:"ImageAndText",
                                text:"Edit"
                        }]
                    },
                    {   
                        field: "Name"
                    },
                    {
                        title:"Roles",
                        template:"#: RoleCSV #",
                        field: "RoleIds",
                        editor: "<select id='RoleIds' name='RoleIds' data-val='true' data-bind='value: RoleIds' multiple style='width:100%'><option value='1'>Admin</option><option value='2'>Guest</option></select>"
                    }
                ],

            dataSource: dataSource,
            model:{
                
            },
            editable: { mode: "inline", update: true}
        });
    });

</script>

Returned data from the read url looks like this:

[{"Id":1,"Name":"Mathieu","RoleCSV":"Admin","RoleIds":[1]},{"Id":2,"Name":"Martin","RoleCSV":"Admin, Guest","RoleIds":[1,2]},{"Id":3,"Name":"Patrick","RoleCSV":"Guest","RoleIds":[2]}]

2 Answers, 1 is accepted

Sort by
0
Mathieu Lafontaine
Top achievements
Rank 1
answered on 17 Jan 2013, 03:55 PM
Anyone?
0
Brett
Top achievements
Rank 2
answered on 17 Jan 2013, 06:39 PM
First thing I notice without running the code is that you have a configuration property in your kendoGrid that does not belong:
model: {
},
Also, remove buttonType in the command column declaration in your kendoGrid. It is not a valid property according to their documentation. I would also change "#: RoleCSV#" to "#= RoleCSV#". The former syntax treats the value as HTML and attempts to encode it, whereas the latter does not.
Tags
Grid
Asked by
Mathieu Lafontaine
Top achievements
Rank 1
Answers by
Mathieu Lafontaine
Top achievements
Rank 1
Brett
Top achievements
Rank 2
Share this question
or