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

How to add custom validation in Grid Textarea

1 Answer 207 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Anoop
Top achievements
Rank 1
Anoop asked on 14 Dec 2016, 11:04 AM

I have custom template like below

schema: {
model: {
id: 'ID',
fields: {
myField: {

        {
          validation: { required: true,
         myfieldvalidation: function (input) {

                                        //Some logic goes here.
                                       input.attr("data-myfieldvalidation-msg", "This is not good");
                                    return false;
       }
}
}

}
}}}

 

and field declaration as

{field: "myField", template: function (dataItem) { return BuildInput(dataItem)}, title: "myField Value"}

calling following function as need logic to build textarea or to show read only. Calling following function just to clear code.

function BuildInput(dataObject) {

   if(editAllowed) {

    return ('<textarea rows="3" cols="4"  type="text" class="k-input k-textbox " name="myField " data-bind="value:myField " ></textarea>');

   } else {

    return dataObject.myField ;

   }

}

This textarea and binding works perfectly. But when I add validation like added above. On blur textarea is changing to input field which I don't want.

How to add validation in Kendo Grid with textArea template.

I have seen this: http://demos.telerik.com/kendo-ui/grid/editing-custom-validation

but above example deals only with input type not textarea.

Moreover, I can workaround with onchange function on textarea but,  onBlur Kendo is regenerating TD content so I can't use my external function to add error message there.

1 Answer, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 16 Dec 2016, 09:34 AM

Hello Anoop,

Maybe I am missing something but the provided code actually does not perform two way binding. Could you please provide a sample dojo example or modify http://dojo.telerik.com/IpoMU with two way binding applied in order to provide some suggestions for the validation? 

Regards,
Boyan Dimitrov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Anoop
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or