how to return error message from server side with popup notification in ui editor template in asp.net core

1 Answer 295 Views
DropDownList Grid
Mohammed
Top achievements
Rank 1
Mohammed asked on 14 May 2021, 07:23 AM

        [HttpPost]
        public JsonResult Create([DataSourceRequest] DataSourceRequest request, License license)
        {

            var x= LicenseRepository.produect.ID==license.productId && LicenseRepository.vendorID==license.VendorId.any();

           if(x==true){

           return error message in cascade dropdown list editor template

            }

 
        }

 

 

@model KendoUIMVC5.Models.License

<script type="text/javascript">
    function filterVendors() {
        return {
            customerId: $("#CustomerId").data("kendoDropDownList").value()
        };
    }

    function filterProducts() {
        return {
            vendorId: $("#VendorId").data("kendoDropDownList").value()
        };
    }
</script>

<fieldset>
    <legend>Cascading DropDownLists:</legend>
    <dl>
        <dt>
            @Html.LabelFor(m => m.CustomerId): 
        </dt>
        <dd>
            @(Html.Kendo().DropDownListFor(m => m.CustomerId)
                  .ValuePrimitive(true)
                  .OptionLabel("Select Customer...")
                  .DataTextField("CustomerName")
                  .DataValueField("CustomerId")
                  .DataSource(dataSource =>
                  {
                      dataSource.Read(read => read.Action("GetCustomers", "Home"))
                                .ServerFiltering(true);
                  })
            )
            @Html.ValidationMessageFor(m => m.CustomerId)
        </dd>
    </dl>
    <dl>
        <dt>
            @Html.LabelFor(m => m.VendorId):
        </dt>
        <dd>
            @(Html.Kendo().DropDownListFor(m => m.VendorId)
                  .AutoBind(false)
                  .ValuePrimitive(true)
                  .OptionLabel("Select Vendor...")
                  .DataTextField("VendorName")
                  .DataValueField("VendorId")
                  .DataSource(dataSource =>
                  {
                      dataSource.Read(read => read.Action("GetVendors", "Home").Data("filterVendors"))
                                .ServerFiltering(true);
                  })
                  .CascadeFrom("CustomerId")
            )
            @Html.ValidationMessageFor(m => m.VendorId)
        </dd>
    </dl>
    <dl>
        <dt>
            @Html.LabelFor(m => m.ProductId): 
        </dt>
        <dd>
            @(Html.Kendo().DropDownListFor(m => m.ProductId)
                  .AutoBind(false)
                  .ValuePrimitive(true)
                  .OptionLabel("Select Product...")
                  .DataTextField("ProductName")
                  .DataValueField("ProductId")
                  .DataSource(dataSource =>
                  {
                      dataSource.Read(read => read.Action("GetProducts", "Home").Data("filterProducts"))
                                .ServerFiltering(true);
                  })
                  .CascadeFrom("VendorId")
            )
            @Html.ValidationMessageFor(m => m.ProductId)
        </dd>
    </dl>
</fieldset>

1 Answer, 1 is accepted

Sort by
0
Tsvetomir
Telerik team
answered on 18 May 2021, 02:22 PM

Hi Mohammed,

Thank you for taking the time to share all the relevant code snippets. Indeed, we do have a very descriptive blog post that elaborates on how to handle the errors - adding them to the ModelState and handling them on the client-side:

https://www.telerik.com/blogs/handling-server-side-validation-errors-in-your-kendo-ui-grid

Let me know if additional information is required.

 

Regards,
Tsvetomir
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
DropDownList Grid
Asked by
Mohammed
Top achievements
Rank 1
Answers by
Tsvetomir
Telerik team
Share this question
or