-
18 Oct 2006 7:56 AM #1
Grid: adding fields to XMLDataModel onLoad
Grid: adding fields to XMLDataModel onLoad
Hi there,
first of all: thx a lot to Jack for all this awesome good work!!
Jack, or anybody else: could U provide me with ideas / recommendation on how to - on the client side - add fields when XML data has finished loading?
An example case: from the server I receive values for eg. loginCount and purchaseCount and have these 2 be shown as cols - now I´d like to add a 3rd column to display the 'login to purchase' percentage there.
How do I do similar the best way? Add a preprocessor to create a new node or similar?
Thx for any idea!
carsten
-
18 Oct 2006 10:13 AM #2
Personally, I would do that at the source of the document. If you have to do it client-side, you could do it by overriding insertRows (and addRows if you use it manually, but internally the grid uses insertRows when loading the XML). You could try something like this, assuming your data model was called dataModel:
1. Define a bogus column in your XMLDataModel schema that won't match any nodes.
2. Override insertRows:
It would useful to add this functionality built in though. I can see where it would definitely be useful. I will look at adding it in a future release.Code:dataModel.insertRows = function(index, data){ //data would be a multi-dimensional array of rows and column data. // loop through each row and set our bogus column (column 5) value // to the sum of column 2 and 4 for(var i = 0, len = data.length; i < len; i++){ var colData = data[i]; colData[5] = colData[2] + colData[4]; } // call the default insertRows YAHOO.ext.grid.XMLDataModel.prototype.insertRows.call(this, index, data); };
Similar Threads
-
Copy & Paste of Rows/Fields in Grid? Is it possible?
By Preston in forum Ext 1.x: Help & DiscussionReplies: 9Last Post: 28 May 2009, 6:43 AM -
XMLDataModel...Adding row dynamically
By booshan in forum Ext 1.x: Help & DiscussionReplies: 0Last Post: 27 Mar 2007, 10:36 AM -
XMLDataModel schema fields XPath support?
By sjivan in forum Community DiscussionReplies: 12Last Post: 16 Dec 2006, 10:00 AM -
Boolean Fields Not Working in Inline Editor Grid
By kyahne in forum Ext 1.x: BugsReplies: 2Last Post: 5 Dec 2006, 1:26 AM -
Grid onload???
By galdaka in forum Ext 1.x: Help & DiscussionReplies: 7Last Post: 30 Oct 2006, 11:53 AM


Reply With Quote