This is a migrated thread and some comments may be shown as answers.
It seems there is a bug with model binding to a list inside editform
4 Answers 32 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Dominic
Top achievements
Rank 1
Dominic asked on 23 Apr 2012, 02:49 PM
Hello,

it seems there is a bug with model binding to a list. Please look at the attached sample, fill all key values and submit. With the grid the array length is always 1 whereas in the normal form it is 3.
Is there any solution for this?

Regards

4 Answers, 1 is accepted

Sort by
0
Dominic
Top achievements
Rank 1
answered on 25 Apr 2012, 07:42 AM
Hello,

in a form i had a similar problem. but i solved the problem like this:

$(function () {
       $('form').submit(function (e) {
           e.preventDefault();
           if ($(this).valid()) {
               var list = new Array();
               $(this).find('input:text[name=keys]').each(function () {
                   list.push($(this).val());
               });
               $.ajax({
                   url: this.action,
                   type: this.method,
                   traditional: true, // this line solves the problem
                   data: { keys: list }
               });
           }
       });
   });
How can i solve this problem/bug with the telerik grid? Regards
0
Dominic
Top achievements
Rank 1
answered on 25 Apr 2012, 08:04 AM
Hello,

if i try this in the onSave event. Then 4 array items will be sent instead  three.

function onSave(e) {
    jQuery.ajaxSettings.traditional = true;
    var values = e.values;
    var list = new Array();
    $(e.form).find('input:text[name=keys]').each(function () {
        list.push($(this).val());
    });
    values['Keys'] = list;
}
0
Dominic
Top achievements
Rank 1
answered on 25 Apr 2012, 02:41 PM
Hello,

i'm about to be resolved. It seems the array name is the problem. If i use an other name and traditional = true 3 items are sent. If the name is "Keys" and traditional = true 4 items are sent. Is there any explanation for this bug/behavior?
Thanks for the help!

Regards,
0
Dominic
Top achievements
Rank 1
answered on 25 Apr 2012, 03:14 PM
Hello,

here is the sample project.
The last problem is that there is always a duplicate or empty entry inside the array. This problem occurs after the binding.


Tags
Grid
Asked by
Dominic
Top achievements
Rank 1
Answers by
Dominic
Top achievements
Rank 1
Share this question
or