kendoDropDownList in edit mode to retain the value and validate

2 posts, 0 answers
  1. spidy
    spidy avatar
    5 posts
    Member since:
    Mar 2018

    Posted 30 Jul Link to this post

    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.


  2. Neli
    Admin
    Neli avatar
    208 posts

    Posted 31 Jul Link to this post

    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.
Back to Top