We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Validation on InlineFormTemplate

Hi Syncfusion etam support
How can i implement the validation to select some of the field for the mandatory field in InlineFormTemplate
My code as below (another code in attachment) and attachment also has been attach
<ej-grid id="GridSearchDiagnosis" allow-paging="true" allow-filtering="true">

<e-datamanager json="ViewBag.datasource"

update-url="/DiagnosisInformation/SaveDiagnosis"

insert-url="/DiagnosisInformation/SaveDiagnosis"

remove-url="/DiagnosisInformation/SaveDiagnosis"

adaptor="remoteSaveAdaptor" />

<e-edit-settings allow-adding="true" allow-editing="true" allow-deleting="true" edit-mode="@(EditMode.InlineFormTemplate)" inline-form-template-id="#templateSearchDiagnosis" />

<e-toolbar-settings show-toolbar="true" toolbar-items="@(new List<string>() {"edit","update","cancel"})">e-toolbar-settings>

<e-columns>

<e-column header-text="ICD 10" field="DiagnosisPartCode"

is-primary-key="false"

is-identity="false"

disable="true"

value="{{:DiagnosisPartCode}}"

width=20 />

<e-column header-text="Diagnosis Name" field="Text"

is-primary-key="true"

is-identity="true"

disable="true"

value="{{:Text}}"

width=70 />

e-columns>

ej-grid>


Thanks for the support


Attachment: InlineFormTemplate_Validation_699baee2.rar

1 Reply

SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team July 26, 2017 12:36 PM UTC

Hi Customer,  
 
We could see you are using a HTML.DropDownListFor. To apply validation to the MVC element, you have to give the ValidationSummary within the form as discussed in the following article. 
 
 
Normally, Grid will handle the validation for all the column if and only if they have been defined with Grid e-columns with the validation-rules. But, in your case, you have added some extra columns in the template form. So, we have handle them externally as discussed above. Refer to the following code example.  
 
<script type="text/template" id="templateSearchDiagnosis"> 
    <table> 
        <tr> 
            <td> 
                Diagnosis Name 
            </td> 
            <td> 
                <input id="Text" name="Text" value="{{: Text}}" disabled="disabled" class="e-field e-ejinputtext valid e-disable" 
                       style="width: 116px; height: 28px" /> 
            </td> 
            <td style="color:red"> 
                Natural History of Illness 
            </td> 
            <td> 
                @Html.ValidationSummary() 
                @Html.DropDownListFor(model => model.NaturalId, ViewBag.lNatural as SelectList, "Select", new { @value = "DiagnosisTypeDesc", htmlAttributes = new { @class = "form-control" } , style = "width: 100%;height: 14px;display: block;font-size: 11px;line-height: 1.428571429;color: #555;vertical-align: middle;background-color: #fff;border: 1px solid #ccc;" }) 
            </td> 
        </tr> 
    </table> 
</script> 
 
Please make a note that the NaturalID must be set with required annotation. Refer to the following code example. 
 
public class EditableOrder 
    { 
        [Required( ErrorMessage = "Selection is a MUST" )] 
        public string NaturalId 
        {                   
            get; 
            set; 
        } 
        . . . 
    } 
 
Regards,  
Seeni Sakthi Kumar S. 


Loader.
Up arrow icon