Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by LeitrimMan on Dec 11, 2009 09:02
open dhtmlx forum
Subgrid and Processor

Hi,

is it possible to use a Dataprocessor for a sub_grid. I have a subgrid which load on 'onSubGridCreated' and I want to be able to use a DataProcessor to mange any updates to this. However, the DataProcessor doesn't seem to pick up any changes on the subgrid. Aso when I add dhtmlxdataprocessor_debug.js, I can see any changes that are made to the main griad, but nothing happens when I make changes in the sub grid - the row itself goes red but no feeback on the dataprocessor debug window

here is my code

jobCalloutGrid = jobTabbar.cells("jobcallout").attachGrid();
jobCalloutGrid.setImagePath('codebase/imgs/');
jobCalloutGrid.setHeader(' ,Crew,Task,Callout,Date,Start,Hours,Rate,Location,Contact,Status');
jobCalloutGrid.setColAlign("right,right,left,left,left,right,right,right,left,left,left");
jobCalloutGrid.setColTypes("sub_row_grid,ed,coro,coro,ed,ed,ed,ed,ed,ed,ed");    
jobCalloutGrid.setInitWidths("30,65," + calloutVarWidth + "," + calloutVarWidth + ",80,60,60,60," + calloutVarWidth + "," + calloutVarWidth + ",100");
jobCalloutGrid.setSkin('light');

crewCalloutdp= new dataProcessor("jobdetail2.php?action=crewcallouts&CalloutID=0");
jobCalloutGrid.attachEvent("onSubGridCreated",function(sub,id,ind,value){        
sub.setSkin('modern');    
    sub.setHeader("Emp #,Name,Mobile,Status,Extra,Late");
    sub.setInitWidths("61,"+ calloutVarWidth + "," + calloutVarWidth + ",80,60,60");
    sub.loadXML("jobdetail2.php?action=crewcallouts&CalloutID="+ id);
    sub.init();
    crewCalloutdp.serverProcessor="jobdetail2.php?action=crewcallouts&CalloutID=" + id;
    crewCalloutdp.init(sub);        
});

//php code
$GetAssignedCrewSQL = "select t4.ClientName,t3.JobName, t5.CalloutDate, t5.StartTime, t7.TaskDesc, t3.Location, t1.CrewID, t1.PayrollNo, t1.crewname, t1.MobileNum, t6.lookuptext as status, t2.CalloutID, t2.extrahrs, t2.lateflag, t2.crewcalloutid from crew t1, crewcallouts t2, jobs t3, clients t4, callouts t5, lookups t6, tasks t7 where t2.calloutid=$_GET[CalloutID] and t2.crewid=t1.CrewID and t5.JobID=t3.JobID and t5.ClientID=t4.ClientID and t5.CalloutID=t2.calloutid and t6.lookupkey='CrewStatus' and t6.lookupvalue=t2.status and t5.TaskID=t7.TaskID";
$resconn->render_sql($GetAssignedCrewSQL,"crewcalloutid", "PayrollNo,crewname,MobileNum,status,extrahrs,lateflag");


Any suggestions?
                
Answer posted by dhxSupport on Dec 14, 2009 05:35
Please check if each sub grid has separate dhtmlxDataProcessor object. Also try to crate new instance of dhtmlxDataProcessor inside onSubGridCreated event handler:

var subGridDp;
mygrid = new dhtmlXGridObject('gridbox');
....
mygrid.attachEvent("onSubGridCreated",function(sub_grid_obj,rId,rInd){
if (rId=="2"){
subGridDp=new dataProcessor("php/update.php");
subGridDp.init(sub_grid_obj);
}
return true;
});

Answer posted by LeitrimMan on Dec 14, 2009 08:50

Hi,

 

I've tried this... but now I am getting an object not found message, i.e. as if the url for the php is invalid (yet when I try this url direclty in a browser I get a correct XML response. Note, this error does not occur if I don't return true in the function...?

heres the revised code..

 

   jobCalloutGrid.attachEvent("onSubGridCreated",function(sub_grid_obj,rId,rInd){  
     sub_grid_obj.setHeader("Emp #,Name,Mobile,Status,Extra,Late");
     sub_grid_obj.setInitWidths("61,"+ calloutVarWidth + "," + calloutVarWidth + ",80,60,60");
     sub_grid_obj.loadXML("jobdetail2.php?action=crewcallouts&CalloutID="+ rId);
     var crewCalloutdp= new dataProcessor("jobdetail2.php?action=crewcallouts&CalloutID="+ rId);
     crewCalloutdp.init(sub_grid_obj);  
     sub_grid_obj.init();
     jobCalloutGrid.setSizes();
     return true;
    });

Answer posted by dhxSupport on Dec 15, 2009 02:43
Sub grid object must be initialized before calling crewCalloutdp.init(sub_grid_obj):

sub_grid_obj.init();
crewCalloutdp.init(sub_grid_obj);  
jobCalloutGrid.setSizes();
return false;

Answer posted by LeitrimMan on Dec 15, 2009 03:28

Hi, thanks for the help. I tried this, however there is still no data being sent to the server, i.e. nothing in the debug window.. Also, I return true, whereas you have return false - when I return false the sub grid is not rendered? Here is the current code..

 

    jobCalloutGrid.attachEvent("onSubGridCreated",function(sub_grid_obj,rId,rInd){  
     sub_grid_obj.setHeader("Emp #,Name,Mobile,Status,Extra,Late");
     sub_grid_obj.setInitWidths("61,"+ calloutVarWidth + "," + calloutVarWidth + ",80,60,60");
     sub_grid_obj.init();
     var crewCalloutdp= new dataProcessor("jobdetail2.php?editing=true&action=crewcallouts&CalloutID="+ rId);
     crewCalloutdp.init(sub_grid_obj);      
     return true;
    });

Answer posted by dhxSupport on Dec 15, 2009 05:29
Please contact directly support@dhtmlx.com and we will send you working example.