Unfortunately I'm stuck on ExtJS 2.2 in a current project, so I'm not sure how well this carries over, but I've done a crudload of work looking though the code, extending Store, GridPanel, and JsonReader and creating a custom ColumnModel etc etc. And this is where I think I am with mapping the Store.load() to GridPanel lifecycle, pulled from some code comments:

   1 //==============================================
   2 // Use the reader to create the data store
   3 //==============================================
   4 // note that I've subclassed Store (as MyQueryDataStore) here. 
   5 // No operational difference in this code, however.
   6 var myStore = new MyQueryDataStore({
   7         url: './json/gridValues.json',
   8         reader: myReaderTest
   9 });
  10 
  11 // How to iterate the data once it's returned, remembering that we're
  12 // dealing with an asynchronous paradigm here.
  13 myStore.on("load", function(s,rs) {
  14         console.log("and we're back");
  15         this.each(function(record) {
  16             //var strFieldName = this.fields.get(3).name;
  17             //console.log('record data from callback: ' + record.get(strFieldName));
  18         });
  19 });
  20 myStore.load(); // AJAX call to get the data happens now.
  21 // the Store is going to call the load method of its local
  22 // HttpProxy...
  23 // this.proxy.load(p, this.reader, this.loadRecords, this, options);
  24 // ... the request sent to the server has a callback referenced to
  25 // the store's loadRepsonse method, which includes a call to read
  26 // the response with the referenced DataReader.
  27 //
  28 // Afterwards, the proxy calls the Store's loadRecords method.
  29 // The already Read response is passed with that call as [o] in
  30 // loadRecords' first parameter.
  31 //      loadRecords : function(o, options, success){
  32 //          ...
  33 //          var r = o.records, t = o.totalRecords || r.length;
  34 //
  35 // And voila.  That's the life of a JSON return to DataStore request.

That's close, anyway. I'll clean up the custom objects at some point and post a tutorial, just to add to my other obsolete technology intros, like the Atari 2600 programming on an OS 9- Mac pages.

One quick editorial comment: The "debug" version of ExtJS, at least at version 2.2, shows a programmer more interested in showing off than creating self-commenting code (though don't miss caveats one and two). If you're not going to comment your code, there's no reason to also obfuscate by hand and tell others (like at least one unhelpful dude employed by Sencha won't stop doing on their forums) that the answers to all your questions will be revealed not by asking for help when you're mentally exhausted (okay, some questions are horrible, but still...), but by forensic examination of ext-all-debug.js. This hand-obfuscation is exactly what you find in ExtJS. The best example I've found so far, unless I've missed something, is in JsonReader.

From my flowerbox:
 * In Ext.data.JsonReader, for some reason, the equivalent variable in readRecords
 * for [fieldManager] (in that case, named [f]) was used to perform the tasks of both
 * [fldColumnArchetype] and [fieldCurrent] variables here.  I think it's just an
 * obfuscation technique (like the reused [v] throughout), as the use here seems
 * to have no relationship with the original fieldManager declaration.  That is,
 * you could have used [foo] in either spot if you'd wanted, but they strangely
 * and unintuitively recycled instead. (Or I've missed something important!) The
 * kingdom for a strongly typed language...
 *
 * There were other occurrences of poorly scoped variables and var choices, like...
 *  var s = this.meta;    // This var only made things *less* self-commenting.  Gone.
 * ... that have been removed from the JsonReader codebase.  It's like the code
 * had been minimally minimized and purposely obfuscated, but only partially so --
 * and that obfuscation done by hand.

And let's just say that variables named r,f,fi,fl,v,g are bad enough before they're reused without even a passing regard for typing.

/end rant

Labels: , , ,