Categories | Question details Back To List | ||
Referencing grid cells after save I want add a link to a row cell after a new record is saved. I need to add the link after the record is saved because I need the "newly created server side row Id" that is returned in XML so I can pass it to the javascript function that the link will call. So I know how to reference the cells but how can I guarantee that the save operation has completed so I can retrieve the new server side row id? Note: I already create javascript URLs from server side when grid is loading existing records. But I wanted to avoid doing full refresh of grid just to populate URLs for a new record. So my sequence would go something like this. 1. Insert new record client (row key = (new Date()).valueOf()) 2. Save new record and return new row id (example --> $xml .= "<action type='insert' sid='" . $rowId . "' tid='" . $newId . "'/>";) 3. After save complete reference row key and use it as parameter in URL javascript function ps. The link is to open an upload window which allows users to upload files associated to a record. So this is why I need to save record first and use primary key in table as parameter. Answer posted by dhxSupport on Jul 15, 2009 03:35 You can use defineAction method or DataProcessor event to check if new row was inserted: dp.defineAction("insert",insert_function) function insert_function(node){ //node.getAttribute("tid") - new row id } Answer posted by Michael on Jul 15, 2009 08:59 dp.defineAction("insert",insert_function)
function insert_function(node) oGrid.cellByIndex(rowIndex, 14).setValue("Upload Video^javascript:uploadVideo(" + rowId + ")^_self"); }
function insert_function(node)
Answer posted by Michael on Jul 15, 2009 09:07 small typo aboe where oGridWorkEstimate.getRowsNum() - 1; should use oGrid. Answer posted by Michael on Jul 15, 2009 09:17 Ok, I figured it out. Its seems I need to use the "client side row id" when using cellById..even after saving. function insert_function() { var rowIdDB = node.getAttribute("tid"); } Answer posted by Michael on Jul 15, 2009 09:22 actually that does not work either. Still only cellByIndex works. Answer posted by Michael on Jul 15, 2009 09:32 Sorry. Yes my final solution does indeed work. cellById works when using the original client row Id after a save. Thanks. Answer posted by Support on Jul 15, 2009 09:35 >>I need to use the "client side row id" when using cellById..even after saving. The order of actions - insert callback received - code attached by defineAction called - native insert related code called ( id of client side record changed ) so, code inside defineAction handler need to use "sid" attribute , because it called before id of row changed to new one Also, be sure to add the next line function insert_function(){ var rowIdDB = node.getAttribute("tid"); var rowIdClient = node.getAttribute("sid"); oGrid.cellById(rowIdClient, 14).setValue("Upload Video^javascript:uploadVideo(" + rowIdDB + ")^_self"); return true; } without it, your custom code blocks default after-insert processing Answer posted by Michael on Jul 15, 2009 09:41 Thank you. Works great now. |