ober Posted May 21, 2010 Share Posted May 21, 2010 So, I spent the past few hours implementing this great EXTJS editor grid: http://www.extjs.com/deploy/dev/examples/grid/edit-grid.html I wrote a routine to pull data out of the database (MSSQL) and dump it to XML so this grid could read and display it. And then I realize that I somehow have to figure out how to get the data BACK INTO the database. Since I can't write the data to anything and store that back to the server using JS... how the hell am I supposed to use this thing? Have I just wasted several hours of research and coding?? I guess one approach would be sending all the data back via AJAX, but there has to be a cleaner approach, right? Has anyone dealt with this? Quote Link to comment https://forums.phpfreaks.com/topic/202535-get-data-into-xml-to-pass-back-to-server/ Share on other sites More sharing options...
Mchl Posted May 21, 2010 Share Posted May 21, 2010 I usually iterate thtough store records, and add them one by one to an array. Then use Ext.util.JSON.encode to make JSON string out of it. Other way to do it, is to hook into 'afteredit' listener of the EditorGrid and send each changed value to the server right after user accepts the changes in given field. Quote Link to comment https://forums.phpfreaks.com/topic/202535-get-data-into-xml-to-pass-back-to-server/#findComment-1061782 Share on other sites More sharing options...
ober Posted May 23, 2010 Author Share Posted May 23, 2010 Do you have any code for the first option you suggested that you wouldn't mind sharing? Quote Link to comment https://forums.phpfreaks.com/topic/202535-get-data-into-xml-to-pass-back-to-server/#findComment-1062113 Share on other sites More sharing options...
Mchl Posted May 23, 2010 Share Posted May 23, 2010 Sure: var data = new Array(); SomeGrid.store.each(function(record)) { data.push(record.data); } var dataJson = Ext.util.JSON.encode(data); Ext.Ajax.request({ url: 'some.url', params: { data: dataJson } }) There's probably a better way to do it, but this works fine. Quote Link to comment https://forums.phpfreaks.com/topic/202535-get-data-into-xml-to-pass-back-to-server/#findComment-1062157 Share on other sites More sharing options...
Ang3l0fDeath Posted May 23, 2010 Share Posted May 23, 2010 I have a webpage that has tons of data as well.... best way i found to edit data or save data is to do it though javascript. Javascript greatly reduced the code on the page, the reason why is the only function i had was <tr><td><input type=button value='Save' onclick="save_data(this);"> I hope you know what ( this ) is, is so read up on it. This will result in an elementObject of the input field. But use your nodes. elementObject.parentNode.parentNode. alert the results of the elementObject that results for each part and stop at the HTML - TR node. After that you can evaluate data each INPUT field or TD field within the TR element. If your understanding why im suggesting this you might find it useful in processing your data back into a AJAX thingy. Personally i would loop each input field into a query string and send that string back to a page that is just meant to recieve data. However you can use the CURRENT page to recieve the data. HOW? Well in PHP you divid your page. 1 page would be recieving POST/GET request. Another would be the output of the normal page which is ur current page. From what i see your good enough with ajax/css/probably php and a few other languages to figure out what solution you need and how to make it work. I hope something here helped. Quote Link to comment https://forums.phpfreaks.com/topic/202535-get-data-into-xml-to-pass-back-to-server/#findComment-1062181 Share on other sites More sharing options...
ober Posted May 24, 2010 Author Share Posted May 24, 2010 Yeah, I've done the whole AJAX thing and I don't have any issues there. My only new issue is that I've never dealt with one of these grids and I don't know how the data is stored or read or retrieved after updating. I'll play around with what Mchl posted and see what I can do with it. Honestly, this is a lot of work when I probably could have created this interface with pure PHP a lot faster... but I want the end user experience to be good so I'm trying to go above and beyond. Quote Link to comment https://forums.phpfreaks.com/topic/202535-get-data-into-xml-to-pass-back-to-server/#findComment-1062742 Share on other sites More sharing options...
Mchl Posted May 24, 2010 Share Posted May 24, 2010 ExtJS makes a lot of sense once you understand how it's built. Grid has a Store, Store is a collection of Records, Records represent individual rows. I can recommend you a really good book, if you're planning to do some more work with Ext. Here's a free chapter with some basic information: http://www.manning.com/garcia/Garcia_MEAPCH1.pdf.pdf Quote Link to comment https://forums.phpfreaks.com/topic/202535-get-data-into-xml-to-pass-back-to-server/#findComment-1062773 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.