Telerik MVC Grid Inline editing requires page refresh to display changes











up vote
0
down vote

favorite












I have a Telerik MVC Grid where I am updating the rows inline (updating name column, number column is uneditable)



 @Html.Kendo().Grid(Model.Employees)
.Name("EmployeeGrid")
.Columns(col =>
{
col.Bound(o => o.EmployeeNumber);
col.Bound(o => o.Name).Width(250);
col.Command(command => { command.Edit(); });
})
.Editable(editable => editable.Mode(GridEditMode.InLine))
.DataSource(dataSource => dataSource
.Ajax()
.Events(e => e.RequestEnd("onGridDataSourceRequestEnd"))
.Model(model =>
{
model.Id(o => o.EmployeeNumber);
model.Field(o => o.EmployeeNumber).Editable(false);
})
.Update(update => update.Action("EditingInline_Update", "EmployeeUpdate"))
.ServerOperation(false)
)
.Render();


function onGridDataSourceRequestEnd(e) {
if (e.type == "update") {
console.log('I am inside Update');
$("#EmployeeGrid").data("kendoGrid").dataSource.read();
}
}


My problem is that above code updates the record by calling action EmployeeUpdate when I click on Update button in the grid. However, that change doesnt immediately reflect in the grid even though I am calling datasource read in JS function. Console shows "I am inside Update" but doesnt refresh grid. If I refresh the page, I do see the update row.



Please let me know what am I missing. Thank you.










share|improve this question


























    up vote
    0
    down vote

    favorite












    I have a Telerik MVC Grid where I am updating the rows inline (updating name column, number column is uneditable)



     @Html.Kendo().Grid(Model.Employees)
    .Name("EmployeeGrid")
    .Columns(col =>
    {
    col.Bound(o => o.EmployeeNumber);
    col.Bound(o => o.Name).Width(250);
    col.Command(command => { command.Edit(); });
    })
    .Editable(editable => editable.Mode(GridEditMode.InLine))
    .DataSource(dataSource => dataSource
    .Ajax()
    .Events(e => e.RequestEnd("onGridDataSourceRequestEnd"))
    .Model(model =>
    {
    model.Id(o => o.EmployeeNumber);
    model.Field(o => o.EmployeeNumber).Editable(false);
    })
    .Update(update => update.Action("EditingInline_Update", "EmployeeUpdate"))
    .ServerOperation(false)
    )
    .Render();


    function onGridDataSourceRequestEnd(e) {
    if (e.type == "update") {
    console.log('I am inside Update');
    $("#EmployeeGrid").data("kendoGrid").dataSource.read();
    }
    }


    My problem is that above code updates the record by calling action EmployeeUpdate when I click on Update button in the grid. However, that change doesnt immediately reflect in the grid even though I am calling datasource read in JS function. Console shows "I am inside Update" but doesnt refresh grid. If I refresh the page, I do see the update row.



    Please let me know what am I missing. Thank you.










    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have a Telerik MVC Grid where I am updating the rows inline (updating name column, number column is uneditable)



       @Html.Kendo().Grid(Model.Employees)
      .Name("EmployeeGrid")
      .Columns(col =>
      {
      col.Bound(o => o.EmployeeNumber);
      col.Bound(o => o.Name).Width(250);
      col.Command(command => { command.Edit(); });
      })
      .Editable(editable => editable.Mode(GridEditMode.InLine))
      .DataSource(dataSource => dataSource
      .Ajax()
      .Events(e => e.RequestEnd("onGridDataSourceRequestEnd"))
      .Model(model =>
      {
      model.Id(o => o.EmployeeNumber);
      model.Field(o => o.EmployeeNumber).Editable(false);
      })
      .Update(update => update.Action("EditingInline_Update", "EmployeeUpdate"))
      .ServerOperation(false)
      )
      .Render();


      function onGridDataSourceRequestEnd(e) {
      if (e.type == "update") {
      console.log('I am inside Update');
      $("#EmployeeGrid").data("kendoGrid").dataSource.read();
      }
      }


      My problem is that above code updates the record by calling action EmployeeUpdate when I click on Update button in the grid. However, that change doesnt immediately reflect in the grid even though I am calling datasource read in JS function. Console shows "I am inside Update" but doesnt refresh grid. If I refresh the page, I do see the update row.



      Please let me know what am I missing. Thank you.










      share|improve this question













      I have a Telerik MVC Grid where I am updating the rows inline (updating name column, number column is uneditable)



       @Html.Kendo().Grid(Model.Employees)
      .Name("EmployeeGrid")
      .Columns(col =>
      {
      col.Bound(o => o.EmployeeNumber);
      col.Bound(o => o.Name).Width(250);
      col.Command(command => { command.Edit(); });
      })
      .Editable(editable => editable.Mode(GridEditMode.InLine))
      .DataSource(dataSource => dataSource
      .Ajax()
      .Events(e => e.RequestEnd("onGridDataSourceRequestEnd"))
      .Model(model =>
      {
      model.Id(o => o.EmployeeNumber);
      model.Field(o => o.EmployeeNumber).Editable(false);
      })
      .Update(update => update.Action("EditingInline_Update", "EmployeeUpdate"))
      .ServerOperation(false)
      )
      .Render();


      function onGridDataSourceRequestEnd(e) {
      if (e.type == "update") {
      console.log('I am inside Update');
      $("#EmployeeGrid").data("kendoGrid").dataSource.read();
      }
      }


      My problem is that above code updates the record by calling action EmployeeUpdate when I click on Update button in the grid. However, that change doesnt immediately reflect in the grid even though I am calling datasource read in JS function. Console shows "I am inside Update" but doesnt refresh grid. If I refresh the page, I do see the update row.



      Please let me know what am I missing. Thank you.







      asp.net-mvc telerik telerik-grid telerik-mvc






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 9 at 2:53









      blue piranha

      1,24573058




      1,24573058
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          You should not have to refresh/reload your grid when doing an update, you just have to return the updated record from the controller and grid-widget will take care of the rest!



          Please checkout telerik demo-page



          The most common error I do is forgetting to return a datasourceresult:



          .ToDataSourceResult(request,ModelState)


          Telerik normally returns the same model that are sent in to the update, but I normally returns the same object that the read function returns (if read does something I'll get that on the updated record too).






          share|improve this answer





















          • Thank you very much. Worked like a charm.
            – blue piranha
            Nov 9 at 12:24


















          up vote
          0
          down vote













          Probably you should try refreshing the grid with refresh() function:



          function onGridDataSourceRequestEnd(e) {
          if (e.type == "update") {
          console.log('I am inside Update');
          $("#EmployeeGrid").data("kendoGrid").dataSource.read();

          // add this line
          $("#EmployeeGrid").data("kendoGrid").refresh();
          }
          }


          Note that read() function in dataSource only reload data source by request to the server, the grid contents still not changed before using refresh().






          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53219186%2ftelerik-mvc-grid-inline-editing-requires-page-refresh-to-display-changes%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote



            accepted










            You should not have to refresh/reload your grid when doing an update, you just have to return the updated record from the controller and grid-widget will take care of the rest!



            Please checkout telerik demo-page



            The most common error I do is forgetting to return a datasourceresult:



            .ToDataSourceResult(request,ModelState)


            Telerik normally returns the same model that are sent in to the update, but I normally returns the same object that the read function returns (if read does something I'll get that on the updated record too).






            share|improve this answer





















            • Thank you very much. Worked like a charm.
              – blue piranha
              Nov 9 at 12:24















            up vote
            0
            down vote



            accepted










            You should not have to refresh/reload your grid when doing an update, you just have to return the updated record from the controller and grid-widget will take care of the rest!



            Please checkout telerik demo-page



            The most common error I do is forgetting to return a datasourceresult:



            .ToDataSourceResult(request,ModelState)


            Telerik normally returns the same model that are sent in to the update, but I normally returns the same object that the read function returns (if read does something I'll get that on the updated record too).






            share|improve this answer





















            • Thank you very much. Worked like a charm.
              – blue piranha
              Nov 9 at 12:24













            up vote
            0
            down vote



            accepted







            up vote
            0
            down vote



            accepted






            You should not have to refresh/reload your grid when doing an update, you just have to return the updated record from the controller and grid-widget will take care of the rest!



            Please checkout telerik demo-page



            The most common error I do is forgetting to return a datasourceresult:



            .ToDataSourceResult(request,ModelState)


            Telerik normally returns the same model that are sent in to the update, but I normally returns the same object that the read function returns (if read does something I'll get that on the updated record too).






            share|improve this answer












            You should not have to refresh/reload your grid when doing an update, you just have to return the updated record from the controller and grid-widget will take care of the rest!



            Please checkout telerik demo-page



            The most common error I do is forgetting to return a datasourceresult:



            .ToDataSourceResult(request,ModelState)


            Telerik normally returns the same model that are sent in to the update, but I normally returns the same object that the read function returns (if read does something I'll get that on the updated record too).







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 9 at 8:28









            Jörgen Moen

            837




            837












            • Thank you very much. Worked like a charm.
              – blue piranha
              Nov 9 at 12:24


















            • Thank you very much. Worked like a charm.
              – blue piranha
              Nov 9 at 12:24
















            Thank you very much. Worked like a charm.
            – blue piranha
            Nov 9 at 12:24




            Thank you very much. Worked like a charm.
            – blue piranha
            Nov 9 at 12:24












            up vote
            0
            down vote













            Probably you should try refreshing the grid with refresh() function:



            function onGridDataSourceRequestEnd(e) {
            if (e.type == "update") {
            console.log('I am inside Update');
            $("#EmployeeGrid").data("kendoGrid").dataSource.read();

            // add this line
            $("#EmployeeGrid").data("kendoGrid").refresh();
            }
            }


            Note that read() function in dataSource only reload data source by request to the server, the grid contents still not changed before using refresh().






            share|improve this answer

























              up vote
              0
              down vote













              Probably you should try refreshing the grid with refresh() function:



              function onGridDataSourceRequestEnd(e) {
              if (e.type == "update") {
              console.log('I am inside Update');
              $("#EmployeeGrid").data("kendoGrid").dataSource.read();

              // add this line
              $("#EmployeeGrid").data("kendoGrid").refresh();
              }
              }


              Note that read() function in dataSource only reload data source by request to the server, the grid contents still not changed before using refresh().






              share|improve this answer























                up vote
                0
                down vote










                up vote
                0
                down vote









                Probably you should try refreshing the grid with refresh() function:



                function onGridDataSourceRequestEnd(e) {
                if (e.type == "update") {
                console.log('I am inside Update');
                $("#EmployeeGrid").data("kendoGrid").dataSource.read();

                // add this line
                $("#EmployeeGrid").data("kendoGrid").refresh();
                }
                }


                Note that read() function in dataSource only reload data source by request to the server, the grid contents still not changed before using refresh().






                share|improve this answer












                Probably you should try refreshing the grid with refresh() function:



                function onGridDataSourceRequestEnd(e) {
                if (e.type == "update") {
                console.log('I am inside Update');
                $("#EmployeeGrid").data("kendoGrid").dataSource.read();

                // add this line
                $("#EmployeeGrid").data("kendoGrid").refresh();
                }
                }


                Note that read() function in dataSource only reload data source by request to the server, the grid contents still not changed before using refresh().







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 9 at 3:27









                Tetsuya Yamamoto

                13.4k41939




                13.4k41939






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53219186%2ftelerik-mvc-grid-inline-editing-requires-page-refresh-to-display-changes%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Schultheiß

                    Verwaltungsgliederung Dänemarks

                    Liste der Kulturdenkmale in Wilsdruff