I have a problem with the following implementation I want to update a dropdownlist in the save event of a grid

2 posts, 0 answers
  1. Mauricio
    Mauricio avatar
    2 posts
    Member since:
    Dec 2014

    Posted 19 Apr Link to this post


    @(Html.Kendo().Grid<MasterSuiteMultiPais.Models.SURVEY>()
            .Name("grid")
            .Columns(columns =>
            {......
     .Events(events => events.Save("Updateddl"))
    ....
    and this is my function to update


     <script type="text/javascript">
        function Updateddl() {
            $("#encuestas").data('kendoDropDownList').dataSource.read()
    or
     var cat = $("#encuestas").data("kendoDropDownList");
            cat.dataSource.read();
            cat.refresh();
        }
            </script>


    but this no have effect the dropdownlist is in the same page an the same controller
    this is the DDL i like to update


        @(Html.Kendo().DropDownList()
                            .Name("encuestas")

                            .HtmlAttributes(new { style = "width:200px" })
                            .OptionLabel("Seleccione una encuesta...")
                            .DataTextField("surv_name")
                            .DataValueField("surv_id")
                            .Events(e => e.Change("change"))
                            .DataSource(source =>
                            {
                                source.Read(read =>
                                {
                                    read.Action("GetSurvey", "Survey");
                                });
                            })
        )


    Gracias!
  2. Stefan
    Admin
    Stefan avatar
    912 posts

    Posted 21 Apr Link to this post

    Hello Mauricio,

    The provided example should successfully update the DropDownList data. Also, the refresh method is not required as the read method refreshes the widget as well.

    I can suggest checking the network tab to observe if the request is sent to the server and also if the response is containing the new data.

    Also, please use the dataBound event of the DropDown to check if it is rebound after the read method is called:

    http://docs.telerik.com/kendo-ui/api/javascript/ui/dropdownlist#events-dataBound

    If additional assistance is needed, please provide a fully runnable example reproducing the issue and I will gladly assist.

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