Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Jeremy Savoy on Jan 21, 2008 20:01
open dhtmlx forum
dhtmlXGrid

Hi,

I am prototyping my site with your grid and a competitor's grid. From their examples I was able to easily create a grid that pulls data directly from a MySQL database. Can you comment on loading data from a database using your tools?

I don't see many similar examples for your grid, however you seem to have the database update on cell edit feature that I really need.

I am already able to dynamically generate XML from the database and load that into your grid using mygrid.loadXML("xml/contacts_xml.php");

For the data processor I have a few questions:

1. When you add a row to the datagrid, can you have a dialog that requires you enter some specific information before the row is allowed to be added?

2. If the row is added to the grid and the database, is the grid updated by the new database entry (maybe with mygrid.setXMLAutoLoading("dynload.php") ? ) or by adding the data to the grid and the database asyncronously? I generate a UUID (primary key) in my database when a record is inserted and that UUID data would only be accurate in the grid (for updates of the record etc) if the data was loaded from the database, unless there is some other method?

Thanks.
Answer posted by Support on Jan 22, 2008 05:42
>>1. When you add a row to the datagrid, can you have a dialog that requires you enter some specific information before the row is allowed to be added?
There are two ways to achieve such behavior
    a) validator function - usage shown on default dataprocessor sample
        http://dhtmlx.com/docs/products/dhtmlxGrid/samples/dataprocessor/savedata_grid.html
    in case if value of cell not confirm rules - row will not be sent to server.

    b) dataProcessor allow to define custom code which will be called before data send to server
    myproc.setOnBeforeUpdateHandler(function(id,type){
       //any custom code here
    });

>>2. If the row is added to the grid and the database, is the grid updated by the new database entry
Yes, the code works in next way
    a) new row added, with some uniqu ID (sid)
    b) data send to server
    c) row added to DB, the real ID generated for row (tid)
    d) server code sends response back to client
       ...
        <action type="insert" sid="sid"    tid="tid" />
       ...
    e) client code parse response and change existing ID (sid) to real ID from DB (tid)

next time when update will be called , it will use correct DB ID