On Sat, Jul 21, 2012 at 07:42:16AM -0700, Rob wrote:
> Hi Craig,
>
> My turn to be a little confused....(!)
> Simplest things first (and my very sincere apologies in advance if I tell
> you anything you already know!!):
> 1. Flexigrid / jqgrid -- two different libraries (functionally and
> feature-wise, the latter is the more powerful)
> 2. TW / TW2 -- two rather different 'engines'
> 3. core.jqGridWidget -- perhaps think of this as access to the raw jqgrid
> and a means of displaying rows of 'data'
> 4. sqla.SQLAjqGridWidget -- a jqgrid which is closely bound to an
> sqlalchemy object model.
>
> As you say, they all work but they (perhaps) serve different purposes. As
> to flexigrid/jqgrid, your choice... but the latter is unquestionably more
> advanced and I find it aesthetically more pleasing (as far as I'm aware
> there's no TW2 widget/wrapper for flexigrid).
>
> As to TW / TW2 (and in fact as per the tutorial you linked to by Ralph
> Bean), in a new project I simply switch TW off and use only the latter. As
> per the docs etc. TW and TW2 can be used in the same project (ie they can
> both be 'switched on' at the same time) but I prefer the syntax of the
> latter and -- here I really hope that I'm not speaking out of line(!) --
> consensus appears to be in favour of TW2, that's certainly where the
> development is most active.
>
> Just very quickly, I'll address the question you asked about having to
> query and "then throw away all but 25 of them". If you look at the
> resulting jqgrid you'll see in the pager/navgrid "page 1 of P" and on the
> right hand side, "records 1 to n of Z", where Z is the total number of
> rows in the recordset. So, very simply let's say there are 10,000 records
> in your table, you've now filtered the recordset to show only those whose
> first name is "Mary", and you're left with 300 records. If you look
> carefully at the code I sent, this will now become immediately apparent
> You query/filter --- and then count the total number records (the Z has to
> come from somewhere, right? :) ) and then limit/offset depending on the
> number of records to display per page (let's say 25) and the page number
> you're on. (that make sense?!)
>
> So, time to close some doors! We're now talking about using jqgrid with
> TW2: your choice of jqGridWidget vs SQLAjqGridWidget... And now it very
> much depends on what it is that you're trying to accomplish and the
> 'object model' you're using. Fundamentally, it's a question about 'layers
> of abstraction':
>
> * the SQLAlchemy ORM sits on top of the 'expression language',
> * SQLAjqGridWidget sits on top of (indeed, inherits from) jqGridWidget.
> * (the jqgrid itself just wants to point at a URL which will give it a
> json representation of the data)
>
> Very broadly speaking, if you have a simple object model and, all things
> being equal, in order to query it you'd use the object model/ORM then the
> SQLAjqGridWidget will almost certainly get you there... Essentially, the
> SQLAjqGridWidget takes the job away from you and constructs the
> [@expose('json')] controller method/query for you -- granted, you lose
> visibility of what exactly is being queried but in a great many cases this
> may well be exactly what you're looking for.
>
> If on the other hand the object model is more complex or you find yourself
> needing (or wanting) to use the expression language directly (don't forget
> that the ORM is an abstraction of the expression language, it's slower and
> provides less fine-grained control) then you will almost certainly have to
> provide the controller method (ie the code snippet that I provided
> earlier) yourself. In a nutshell, if you want full control of the query
> you'll be using jqGridWidget.
>
> I really hope that this explanation has revealed more than it's obscured,
> but if you still have questions I'd be happy to try and help.
It sure did clear things up Rob, thanks as its helped and I've got a
clear path ahead now. A lot of my queries are not simple ones so that
is sounding like your first suggestion is the way to go.
This is probably a sqlalchemy question, but where does the SQLa hit the
database? You see on line 4 you do your query, but line 8 you have limit
and offset, between those lines its not pulling the entire set of rows
in and then in line 8 throwing it away. I'm from the php mysql function
days so is it just a matter of 'sqlalchemy does the right thing
normally, dont worry about it'?
--
Craig Small VK2XLZ http://enc.com.au/ csmall at : enc.com.au
Debian GNU/Linux http://www.debian.org/ csmall at : debian.org
GPG fingerprint: 5D2F B320 B825 D939 04D2 0519 3938 F96B DF50 FEA5
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en.