javascript - Kendo grid expand row not working correctly -


i have kendo grid populated sql database. kendo expand works fine , returns different kendo grid in expand when program first starts if new search , return different results expand row not work.

my code expand ->

function detailinitd(e) {     textvaluefile  = "manno test";     $.ajax({     type: "post",     data: json.stringify({         search_string: textvaluefile,     }),     url: "/search.aspx/file_search",     datatype: "json",     contenttype: 'application/json',      success: function (object) {         response(object);     },     complete: function (object) {      },     error: function (object) {     } }); function response(object) {     var grid = this;      $("<div/>").appendto(e.detailcell).kendogrid({         datasource: {             data: object.d,             schema: {                 model: {                      path: { type: "string" },                     st_size: { type: "number" },                  },             },             pagesize: 20,         },         reorderable: true,         resizable: true,         navigatable: true,         selectable: "multiple",         scrollable: true,         sortable: true,         filterable: true,         columnmenu: true,         pageable: {             input: true,             numeric: true         },          columns: [             { field: "path", title: "path", width: 200 },                 { field: "st_size", title: "size", width: 60 },                  { field: "st_blks", title: "blks", width: 60 },                   { field: "st_acctime", title: "acc time", width: 70 },                    { field: "st_modtime", title: "mod time", width: 75 },          ]      });  } }; 

my code original kendo grid ->

function displaysearch() {     } texts.value = value;     valsearch = texts;     $.ajax({         type: "post",         data: json.stringify({             search_string: valsearch,         }),         url: "/search.aspx/display_search",         datatype: "json",         contenttype: 'application/json',          success: function (object) {             response(object);         },         complete: function (object) {          },         error: function (object) {         }     });     function response(object) {         $("#searchgrid").kendogrid({             theme:"default",             datasource: {                 data: object.d,                 schema: {                     model: {                         archive_header_key: { type: "number" },                         group_name: { type: "string" },                         server: { type: "string" },                         archive: { type: "string" },                         display_name: { type: "string" },                         file_written: { type: "number" },                         session_id: { type: "string" },                         create_browse: {type:"number"},                     },                 },                 pagesize: 20,                                 },             detailinit: detailinit,             databound: function () {                 this.expandrow(this.tbody.find("tr"));             },             reorderable: true,             navigatable: true,             selectable: "single",                           scrollable: true,             sortable: true,             filterable: false,             columnmenu: true,             reordable: true,             resizable: true,               pageable: {                 input: true,                 numeric: true,               },         columns: [             { field: "archive_header_key", title: "key", width: 50 },             { field: "server", title: "server", width: 75 },             { field: "group_name", title: "group", width: 75 },             { field: "archive", title: "archive", width: 50 },              { field: "display_name", title: "display name", width: 300 },             { field: "file_written", title: "files", width: 50 },              { field: "session_id", title: "session", width: 200 },              {field: "create_browse", title:"browse", width: 50},         ],         change: function(){              var grid = this;              grid.select().each(function(){                 var dataitem = grid.dataitem($(this));                 testdata = dataitem.archive_header_key;                 grid.expandrow(grid.element.closest("tr"));                           })         },         databound: function () {             this.expandrow();         },          });       }        

any appreciated.

i think duplicated instances. when searching, , call response() instanciate kendogrid probably, have like:

declare variable out of response() like:

var $searchgrid = null; 

and change response() :

function response(object) {       if($searchgrid){         $searchgrid .destroy();         $("#searchgrid").empty();         $("#searchgrid").remove();         }          $("#searchgrid").kendogrid({             theme:"default",             datasource: {                 data: object.d,                 schema: {                     model: {                         archive_header_key: { type: "number" },                         group_name: { type: "string" },                         server: { type: "string" },                         archive: { type: "string" },                         display_name: { type: "string" },                         file_written: { type: "number" },                         session_id: { type: "string" },                         create_browse: {type:"number"},                     },                 },                 pagesize: 20,                                 },             detailinit: detailinit,             databound: function () {                 this.expandrow(this.tbody.find("tr"));             },             reorderable: true,             navigatable: true,             selectable: "single",                           scrollable: true,             sortable: true,             filterable: false,             columnmenu: true,             reordable: true,             resizable: true,               pageable: {                 input: true,                 numeric: true,               },         columns: [             { field: "archive_header_key", title: "key", width: 50 },             { field: "server", title: "server", width: 75 },             { field: "group_name", title: "group", width: 75 },             { field: "archive", title: "archive", width: 50 },              { field: "display_name", title: "display name", width: 300 },             { field: "file_written", title: "files", width: 50 },              { field: "session_id", title: "session", width: 200 },              {field: "create_browse", title:"browse", width: 50},         ],         change: function(){              var grid = this;              grid.select().each(function(){                 var dataitem = grid.dataitem($(this));                 testdata = dataitem.archive_header_key;                 grid.expandrow(grid.element.closest("tr"));                           })         },         databound: function () {             this.expandrow();         },          }).data("kendogrid");;       }      

hope help


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -