custom type loading

I’m trying to get the custom type loading for grids to work, but I don’t seem to manage :slight_smile:

Keep getting the message: Error: ‘this.obj.firstChild’ is null or not an object
this happens after the custom rowloader has been invoked. When debugging, the row.childNodes.length seems to be 0.

on the support page of the custom loading (dhtmlx.com/docs/products/dhtmlxG … types.html), the codesample gives a 404.
dhtmlx.com/docs/products/dhtmlxG … sample.zip

code for calling the grid initialize:

var g= l.cells("c").attachGrid();
defineCustomLoader(g);
g.parse("<structures><structure><id>text</id><versionId>text</versionId><createdBy>String</createdBy></structure></structures>", "custom_xml");

the custom loader function:

function defineCustomLoader(grid){
			// the central loader			
			grid._process_custom_xml=function(xml){
            this._parsing=true;
			
			if (!xml.doXPath){
				var t = new dtmlXMLLoaderObject(function(){});
				if (typeof xml == "string") 
					t.loadXMLString(xml);
				else {
					if (xml.responseXML)
						t.xmlDoc=xml;
					else
						t.xmlDoc={};
					t.xmlDoc.responseXML=xml;
				}
				xml=t;
			}
		
            var rows = xml.doXPath("//structure");                     // get all row elements from XML
			
            for (var i = 0; i < rows.length; i++){
                var id = this.getUID();                                // XML doesn't have native ids, so custom ones will be generated
                this.rowsBuffer[i]={                                   // store references to each row element
                    idd: id,
                    data: rows[i],
                    _parser: this._process_custom_xml_row,   // cell parser method
                    _locator: this._get_custom_xml_data        // data locator method
                    };
 
                this.rowsAr[id]=rows[i];                             // store id reference
            }
 
 
 
            this.render_dataset();                                   // force update of grid's view after data loading
            this._parsing=false;
			}	

			// the row parser
			grid._process_custom_xml_row=function(r, xml){	
			
				alert('custom rowloader invoked..');
				
				var size = this.xmlLoader.doXPath("./versionId", xml)[0];        // get size sub-tag
				alert(size.data);
				var mode = this.xmlLoader.doXPath("./createdBy", xml)[0];    // get mode sub-tag
				var strAr = [  
					size.firstChild.data,
					mode.firstChild.data
				];
	 
			   // we don't need any custom attributes, so set just a plain array
				r._attrs={};
				for (j=0; j < r.childNodes.length; j++) r.childNodes[j]._attrs={};
				
				//finish data loading   
				this._fillRow(r, strAr);
				return r;
			}	

			grid._get_custom_xml_data=function(r, xml){
				alert("data function invoked..");
			}
		}

thx,

-Joost

Actually, the code which you have provide works correctly locally.
Check the attached sample.
1272876523.zip (55.4 KB)