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

kendoDropDownList in edit mode to retain the value and validate

1 Answer 957 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
spidy
Top achievements
Rank 1
spidy asked on 30 Jul 2018, 07:11 AM

I am using kendoDropDownList in a kendogrid.
Now when I edit that row by calling 

    grid.editRow(tr);

function, row opens for Edit.

Its shows kendoDropDownList in edit mode but its not able to retain the original value.

I tried using databound event to select original value 

    let input = $('<input name= "' + options.field + '" required = "required"/>');
        input.attr('id', options.field);
        input.attr('data-text-field', 'Name');
        input.attr('data-value-field', 'Name');
        input.attr('data-bind', 'value:' + options.field);
        input.width(container.width());
        input.appendTo(container);
        input.kendoDropDownList({
          autoBind: false,
          dataTextField: 'Name',
          dataValueField: 'Name',
          optionLabel: 'Select',
          dataBound: (e) => {
            $('#' + options.field).data('kendoDropDownList').value(options.model.dropDownValue) ;
          },
          dataSource: {
            data: this.list
          }
        });

If I do this and just call validate 

    $('#grid').kendoValidator().data('kendoValidator').validate();

It shows me validation message for kendoDropDownList.

Since when I open in edit mode, I am setting value of dropdownlist. So why its showing validation message even if its value is set in databound event.

Am I doing something wrong here?

 

Is there an example for kendogrid containing kdropdownlist and doing validation in edit mode.


1 Answer, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 31 Jul 2018, 03:04 PM
Hello Spidy,

As far as I understand you need to set programmatically different value to a cell with custom editor. If this is the case, you could try using the model. The model is available within the edit event arguments (e.model). 
e.model.set("Category.CategoryName", "Produce");

I have prepared a Dojo example. In the sample there is a Grid with inline editing and DropDownList as a custom editor for one of the columns. When the Grid is loaded, the editRow method is called for the third row. The value in the 'Category' column is changed to 'Produce'.


Regards,
Neli
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
DropDownList
Asked by
spidy
Top achievements
Rank 1
Answers by
Neli
Telerik team
Share this question
or