3.0 beta 2

is there a way to get the first 15 rows of the grid?

hello,

i was wondering if there was a way to get the first 15 rows of the grid AS it is presently displayed on the page (i.e., not by just traversing the array that is used to populate the grid). I'm trying to get the first 15 rows when the user clicks a button on the form. Could someone point me in the right direction? Any help is greatly apprecieated.

thanks,

JJ
JJ
February 24,
JJ,
I think what you're referring to is the Rowindex vs RowPosition...
Although not exactly the answer, The demo does show you how to this all works... and some rough idea on where to go from here...
try this then let me know it it expalains the principle well enough for you to proceed...
-geoff
/datagrid.11417/basic-knowledge-demo-lastrow-value.html
G CAYMAN
February 24,
I also should have probably also added that I'm using version 1.0
JJ
February 24,
o.k., got it.

for anyone else that is interested:

var element = grid.getDataProperty("text", rowIndex, columnIndex)

where rowIndex and columnIndex are either user-defined or programatically obtained via some routine. that's just to get one element, obviously, loop it as you see fit to get needed results.

thank you very much for your help regardless, though.

dyn-O-mite!!!!!


JJ
February 24,
the only thing though, it always returns the elements with respect to with which sorting the grid was originally loaded, and now how the grid appears at the moment of request. that's kind of a bummer. I'm going to see if I can find a workaround that crap and post what i get (if i'm successful, that is). but, if anyone else knows how to do it already, please, feel free; I would greatly appreciate it.
dj DD
February 24,
that should have been **not** how the grid appears at the moment of request in the post above. thanx
dj DD
February 24,
dj DD is right, when the grid is resorted, and you ask for the first element in the grid the way JJ posted, you get the original first element (from when the grid loaded), and not the first element after the grid was resorted. there's gotta be a way to do this, though, I can't believe we're the only people that have had to do this. i'll let you guys know if i figure it out.
strailer
February 24,
I would actually like to see how that could be done as well. There has to be an easy way to obtain the first N rows as they appear on screen at the moment of request without really knowing (or caring) how the entries are sorted. I have no idea how to do that, though, but I would find it EXTREMELY USEFUL ;)

Thank you,

--Steve.
Steve Downs
February 24,
any ideas?
JJ
February 27,
The grid (v1) keeps array of row indices, which can be retrieved with obj.getRowProperty("values"); -

// this code is for version 1.0.x !!!
function getRows(){

    var rowCount = obj.getRowProperty("count");
    var rowIndicesArray = obj.getRowProperty("values");
    var i, rowIndex, colIndex = 0, text, results = [];

    for (i=0; i<rowCount; i++){
        rowIndex = rowIndicesArray[i];
        text = obj.getDataProperty("text", rowIndex, colIndex);
        results.push(text);
    }

    alert(results);
}

Alex (ActiveWidgets)
February 27,
cool, thanx a lot alex. keep up the good work.
JJ
February 27,
Thanks, Alex. This works.
dj DD
February 27,
O.k., that worked. One more small thing, though... Does anyone know how to find out how the user sorted the grid when the page is submitted? I couldn't find anything in forums... :-(

Thanks in advance,

Steve.
Steve Downs
February 27,
you know what, I actually did see that in a forum somehwere, but I can't find it anymore.

you want to find out by which column the grid is sorted when the form is submitted, right (like, what column the user clicked)?
JJ
March 1,
Yes, do you know how to do that?
Steve Downs
March 1,
no idea. let's see if alex or somebody smart (as opposed to me) posts anything ;)
JJ
March 1,
I look for same thing for days now. Please post how do it? Thank you.
Ralph Massi
March 1,
Can you even do it in version 1.0?
strailer
March 1,
I don't know. That's what I'm hoping. I'm pretty much at a standstill right now because I know there's probably an easy way to do that and I don't want to devise my own function that determines sorting since it would probably be much slower, and the performance time will not be linear, but rather exponential depending on the size of the grid.
Steve Downs
March 1,
You can get sorting state from the sort model -

// v 1.0
var column = obj.getSortProperty("index");
var direction = obj.getSortProperty("direction");

// v 2.0
var column = obj.getSortColumn();
var direction = obj.getSortDirection();
Alex (ActiveWidgets)
March 1,
you just want the JS function, though, right?
dj DD
March 1,
Wow, never got a response that fast before :). Yes, that is all I needed. Thank you. BTW, is there a place where these functions are documented (like, a refference guide of some sort)?
dj DD
March 1,
What you see on the site is what you get, from my understanding.
Steve Downs
March 1,
Thank you, Alex.
Steve Downs
March 1,
Well, probably if you start at

/aw.ui.grid/

then look at sort model

/aw.ui.grid/sort-model.html

and then on sort column, sort direction -

/aw.ui.grid/sort-column.html
/aw.ui.grid/sort-direction.html

Alex (ActiveWidgets)
March 1,

This topic is archived.

See also:


Back to support forum

Search

Version 2

Looking for AW 2.6 ?
The old site is here.