0
votes

Following a few examples online and even here, I've come close to keeping the popup editor open after a server error is returned.

The event is actually being called (error and databind), but after executiing e.PreventDefault() after clicking update, the window keeps closing all the time. Any idea guys ? (Thanks)

 dsBranches = new kendo.data.DataSource({
          error: function (arg) {
              var _grid = $("#branchesGrid").data("kendoGrid");
              try {
                      _grid.one("dataBinding", function (e) {
                          e.preventDefault();
                      });
             }
              catch (ee){};
          },

          transport: {
              read: {
                  url: "admin/branch/getBranches",
                  dataType: "json"
              },
              update: {
                  url: "admin/branch/updatetBranches",
                  contentType: "application/json",
                  dataType: "json",
                  type: "POST"
              },
              parameterMap: function (data, operation) {

                  if (operation != "read") {
                      return kendo.stringify(data);
                  }
                  else {
                      return kendo.stringify(data);
                  }
              }
          },

          schema: {
              errors: "error",
              model: {
                  id: "Id",
                  fields: {
                      Name: { type: "string", validation: { required: { message:       "Name is empty" } } },
              }


 },
1

1 Answers

0
votes

Seems like when binding the dataBinding to an anonymous function, it will get called only that time. But it so happens that clicking update on the editor triggers a few other actions (rebind (2 more times) , sync). For this reason, I just decided to keep to capture the dataBinding event on the grid and check for a flag in case there was an error. This will issue the preventDefault for any other cascading triggers that might happen later on.

gridBranches = $('#branchesGrid').kendoGrid({
          dataBinding: function (e) {

              if (editHasErrors)
              {
                  e.preventDefault();
                  editHasErrors=0;
              }
          },