Is this possible:
1. User enters data into a cell on the grid (ie NAME)
2. On server side, the data from the cell is changed to lower case (very simple example)
3. New lower-case version of the data is stored in DB
4. Grid receives message that update was successful… AND
5***** Grid properly displays new value (lower case version of data)
I realize I can format the data-entry on the client side, prior to sending to server.
I want to change the data on the server side, but have the client side (grid) reflect it.
If this functionality can be done using Connector and Dataprocessor… GREAT! If not, please provide examples (or links)
I have standard version (ie not pro).
If functionality is only available in Pro version, please let me know…but could you still please show a detailed example/solution for how to do this (in pro version)
I’ll be moving to pro version by next week.
This functionality can be implemented in standard version of Connectors and DataProcessor.
After updating is finished you can catch it on the client side and change necessary values in the grid.
Please find more information here dhtmlx.com/dhxdocs/doku.php?id=d … fterupdate
Ok, so the client side is now working for me. The problem is on the server side.
I use this in my php file:
if(!$gridConn->is_select_mode()){
$DCwriteTable = “tbl_contacts”;
$DCwriteID =“contact_ID”;
$DCwriteFields = “name_last, name_first”;
$gridConn->event->attach(“beforeUpdate”,customUpdateQueryFunction);
$gridConn->render_table($DCwriteTable, $DCwriteID, $DCwriteFields);
exit;
}
//here is my custom function:------------------------------------------ NOTE: I’ve simplified this quite a bunch, to make it clearer…
function customUpdateQueryFunction($action)
{
$updateQry =“UPDATE tbl_contacts SET “;
$updateQry=$updateQry.“name_last=’{$action->get_value(“name_last”)}’,”;
$updateQry=$updateQry.“name_first=’{$action->get_value(“name_first”)}’”;
$updateQry =$updateQry.” WHERE contact_ID={$action->get_id()}”;
$success=mysql_query($updateQry);
if ($success){
… WHAT DO I DO HERE???..I want to output custom XML… so I can add attributes, userdata, etc
Ive tried this: echo (‘test’); but it doesn’t work unless I also put: $action->success();
$action->success(); works fine… but I believe the connector then overrides my custom xml
If I don’t include this line ($action->success()) then the grid text goes bold, but never “resolves”.
} else {
$action->set_response_text(“SQL query error”);
$action->error();
}
}
PS. i noticed that my xml didn’t have quotations around sid and tid values… so I fixed that.
also, please note the ! in if(!$gridConn->is_select_mode()){ //
I tried adding this to the client side: main_dataprocessor.defineAction(“my_actiontype”,alert(“hello”));
and this to the php:
if ($success) {
echo (‘test’);
exit;
}
I get the alert: “hello” when the grid first loads… but not after udpating data in the grid.
When I update data in the grid, the data is changed in the database, but the grid still has the text in BOLD, as if it is waiting for an update.
I’ve tried every combination I can think of.
Do you have a simple html/javascript file and a simple php file which show this functionality working?
1. advanced XML configuration of grid (ie I use custom php function to get data from database and write xml ‘line-by-line’ so I have alot of customization, but you could simply output STATIC xml to populate the grid)
2. data changes on the grid will trigger a CUSTOM function in php (this would update database in my application. For this example, it doesn’t need to do anything, except output xml response.
3. custom PHP (see #2) outputs a xml response, which includes custom action (ie my_action), user data, etc…
4. client side recognizes the custom action, and
a) displays the xml_node information in an alert box (so I can see action=“my_action” etc)
b) changes the value of one cell in the grid via API (to demonstrate that once my_action is interceppted, it can effect the grid)
c) grid updates (text no longer bold)
FYI: I managed to work around this by not using the connector (doing it all with custom php, generating the appropriate xml)…
I have alot to learn yet. I really need to get the pro version. I keep questioning if I’m doing something wrong, or if the feature I want is just not available. Usually, I’m just doing something wrong.
if ($success) {
>> echo (’<action
Connector blocks any direct output during response generation, so it will not work
>> but the grid still has the text in BOLD, as if it is waiting for an update
Response contains incorrect sid attriubute and grid can’t detect for which row confirmation is received.
You can try to include dhtmlxdataprocessor_debug.js in addition to existing js files , it will show exact response text and status of all updates.
>>1. advanced XML configuration of grid
Not supported in connectors 0.9, beta version of Connector 1.x package contains
samples\grid\10_config.html
>>2. data changes on the grid will trigger a CUSTOM function in php
>>3. custom PHP (see #2) outputs a xml
function customUpdateQueryFunction($action)
{
$updateQry = … same code as you are currently using …
$action->success();
//config xml output
$action->set_response_xml(“any text”);
$action->set_response_attribute(“any attribute name”,“any value”)
$action->set_status(“custom_one”); //set custom action@type - details below
}
Be careful with set_status command, client side code awaits one of standard response types and may behave incorrectly if it is not received ( nor mark row as saved for example )
You can use default response type, but store custom data in attributes or in the content of action tag.
>>4. client side recognizes the custom action, and
dp.defineAction(“update”,function(tag){
var id = tag.getAttribute(“sid”);
var value = tag.getAttribute(“custom1”); //assuming that you have used set_response_attribute(“custom1”,“some value”);
grid.cells(id,0).setValue(value);
return true; //allow default logic
})
>>I managed to work around this by not using the connector (doing it all with custom php, generating the appropriate xml)
The connector is just a wrapper, which is used for xml generation. It simplify basic tasks, but for complex scenarios custom solution can be used - it is normal practice.