javascript - Posting a large change set in MVC using Slickgrid -
i attempting optimize mvc app utilizes slickgrid grid edits. grid can anywhere 500-25,000 rows long , has 40 columns. grid works great, i've had problem posting changed info controller in order update sql-side table.
my saving troubles caused post limits in mvc. have edited maxallowedlengths in web.config , tried anything. if post infinite amounts of data, think it's possible work smarter, not harder.
here's attempted psuedo-code show how save data:
function save(data) { var changeddata = []; for(i = 0; < data.length, i++) { if(data[i].ischanged == 1) { changeddata.push(data[i]); //this array of changed objects contains //propertys/columns can changed. 30 in total. } } //i can post little more 5000 rows, else , 500 error due //do size of json string. if (changeddata.length < 5000) { $.ajax({ type: "post", url: url, data: json.stringify(changeddata), success: success }); }else { //break changeddata chunks of 5000 , loop through ajax call. } }
here's how i'm attempting save changes. involves saving changes in queue, sending controller, , executing sequentially on info server-side.
var pendingchanges = []; function save(data) { //i able in 1 go instead of chunking out changes //and finding way store them server side before aggregating , running them. $.ajax({ type: "post", url: url, data: json.stringify(pendingchanges), success: success }); } grid.oncellchange(....) { //update info in cell pendingchanges.push(id:item.id, property:xxx,value:item.value,timestamp:now); } function masscellchange() { var changedrows = []; (i = 0; < data.length; i++;) { if (slickgriddataviewcontainsthisitem) { changedrows.push(data[i].id); //update slickgrid } } pendingchanges.push(id:[changedrows],property:xxx,value:item.value,timestamp:now); }
on controller side, long can create method, have no problems. there utilize javascriptserializer or jsonconvert break out changeset model.
i'm open other patterns can used save big changesets. there features allow users edit entire grid in 1 go, visible in dataview, number of changes single user can generate can quite huge. i've thought of sending global command single pending change, have failed find elegant way post rows visible when alter run. (setting id: property array of ids has proved not work. same issue post limitations.)
thank help!
it's been time, thought post workaround. instead of attempting post lots of work after user attempted clicked "save", broke autosave. essentially, each time user made edit, force object column name,rowid, , new value array. when autosave fired, run through queue of changes, taking latest value each cell. seems simple plenty , sort of 'duh' moment. doing improved response time of app. users happier work beingness saved continuously instead of @ end of task.
by sending simplified queue of columns, rowids, new value, able cutting downwards lot of beingness sent. think run through "script" of changes rebuild objects in middle end update database with.
javascript ajax asp.net-mvc-4 slickgrid
No comments:
Post a Comment