如何在表单ajax中设置kendo grid数据源成功?

问题描述 投票:0回答:1

通过对话框我上传excel文件,并解析服务器上的文件,然后将json数据返回给ajax成功,但是当我想在ajax成功中设置kendo网格数据源时,它再次提交表单,这是我的代码,谁能帮帮我?非常感谢! ajax代码:

var form = $('#idForm');
form.submit(function (e) {
    var formData = new FormData($(this)[0]);
    $.ajax({
        type: form.attr('method'),
        url: form.attr('action'),
        data: formData,
        cache: false,
        processData: false,
        contentType: false,
        dataType: 'json',
        async: false,
        success: function (response) {
            var grid = $('#demo2').data('kendoGrid');

            var dataSource = new kendo.data.DataSource({
                data: response.data
            });

            grid.setDataSource(dataSource);
        },
        error: function (e) {
            alert(123);
        }
    });
    //e.preventDefault(); // avoid to execute the actual submit of the form.
    return false;
});
ajax forms kendo-ui grid
1个回答
0
投票

这是我的解决方案:

  $.ajax({
  type: "get",
  url: path + "GetThings",
  data: { searchCrit: searchCrit },
  datatype: "json",
  traditional: true,
  success: function (result) {
      $("#theList").kendoGrid({
          dataSource: {
              data: result
          },
          columns: [{...}]
  });
© www.soinside.com 2019 - 2024. All rights reserved.