Michelle D'Souza wrote:
Hi,

Last week it was mentioned in the channel that it would be useful to get together as a group to discuss the Pager API prior to the 1.1 feature freeze. I've scheduled a meeting tomorrow at 11:00 am Eastern for us to talk about this. Let's meet in Breeze.
I think I have a meeting at this time. If I don't I might drop in and lurk, but if I can't my biggest suggestion is to add a constructor option for 1.1 that allows to specify the amount of data. I know a lot of the focus is on building cool integrated things backed by models, but the pager is incredibly useful javascript to just plop on a random page and let it do the math for you, so it'd be great for it to just work by specifying the total number of things you want to page. And making it easy to change that number at any time if your volume of stuff changes. Right now I'm hacking this by going:

/*
  * Set up the pagers
  */
// I'm getting a too much recursion error when using my component tree, using a simple array for now.
 var fakedata = [];
 for (var i = 0; i < asnn2.pageState.dataArray.length; i++) {
   fakedata.push(i);
 }

 var pager = fluid.pager("#asnn-list-area", {
   listeners: {
     onModelChange: function (newModel, oldModel) {
// We need to store the pageModel so that the Sorting links can use it when they need
       // to refresh the list
       asnn2.pageState.pageModel = newModel;
       asnn2.renderAsnnListPage();
     }
   },
   dataModel: fakedata,
   pagerBar: {type: "fluid.pager.pagerBar", options: {
     pageList: {type: "fluid.pager.renderedPageList",
       options: {
         linkBody: "a"
       }
     }
   }}
 });


Also, a convenience method to figure out what to render. If you just want to 'use' the pager, this is some error prone math that would be nice to have easily accessible. I'm guessing there is actually something like this already (since it has to calculate it for rendering the databound version) and I just haven't found it in the API yet.

But just in case there isn't.

/**
* Determine the slice to render based off a pageModel.
* @param {pageModel} Page model from the Fluid Pager. This is the object model you get whenever it
* changes.
* @return {Array} An array consisting of the start and end to use. ex. [10,14]
*/
asnn2.findPageSlice = function(pageModel) {
 var start = pageModel.pageIndex * pageModel.pageSize;
var end = start + Number(pageModel.pageSize) - 1; // This was getting coerced to String addition
 if (end > (pageModel.totalRange-1)) {
   end = pageModel.totalRange-1;
 }
 return [start,end];
};

Sorry, my javascript still sucks, I'm sure there's a better way to cast that stuff.

Also, apologies if this has been discussed already. (I have 1333 unread messages in my Fluid email folder at the moment :p ).

Just wanted to mention this stuff since we are using it, testing on preprod now, and Asnn2 will be using it on prod in June. Great stuff, just needs some convenience methods for various things in future versions of the API's.

Megacheers,
Steve

Michelle

------------------------------------------------------
Michelle D'Souza
Software Developer, Fluid Project
Adaptive Technology Resource Centre
University of Toronto



_______________________________________________________
fluid-work mailing list - [email protected]
To unsubscribe, change settings or access archives,
see http://fluidproject.org/mailman/listinfo/fluid-work

_______________________________________________________
fluid-work mailing list - [email protected]
To unsubscribe, change settings or access archives,
see http://fluidproject.org/mailman/listinfo/fluid-work

Reply via email to