:: Forum >>

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
Friday, February 24, 2006
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
http://www.activewidgets.com/javascript.forum.11417.3/basic-knowledge-demo-lastrow-value.html
G CAYMAN
Friday, February 24, 2006
I also should have probably also added that I'm using version 1.0
JJ
Friday, February 24, 2006
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
Friday, February 24, 2006
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
Friday, February 24, 2006
that should have been **not** how the grid appears at the moment of request in the post above. thanx
dj DD
Friday, February 24, 2006
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
Friday, February 24, 2006
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
Friday, February 24, 2006
any ideas?
JJ
Monday, February 27, 2006
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)
Monday, February 27, 2006
cool, thanx a lot alex. keep up the good work.
JJ
Monday, February 27, 2006
Thanks, Alex. This works.
dj DD
Monday, February 27, 2006
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
Monday, February 27, 2006
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
Wednesday, March 1, 2006
Yes, do you know how to do that?
Steve Downs
Wednesday, March 1, 2006
no idea. let's see if alex or somebody smart (as opposed to me) posts anything ;)
JJ
Wednesday, March 1, 2006
I look for same thing for days now. Please post how do it? Thank you.
Ralph Massi
Wednesday, March 1, 2006
Can you even do it in version 1.0?
strailer
Wednesday, March 1, 2006
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
Wednesday, March 1, 2006
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)
Wednesday, March 1, 2006
you just want the JS function, though, right?
dj DD
Wednesday, March 1, 2006
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
Wednesday, March 1, 2006
What you see on the site is what you get, from my understanding.
Steve Downs
Wednesday, March 1, 2006
Thank you, Alex.
Steve Downs
Wednesday, March 1, 2006
Well, probably if you start at

http://www.activewidgets.com/aw.ui.grid/

then look at sort model

http://www.activewidgets.com/aw.ui.grid/sort-model.html

and then on sort column, sort direction -

http://www.activewidgets.com/aw.ui.grid/sort-column.html
http://www.activewidgets.com/aw.ui.grid/sort-direction.html

Alex (ActiveWidgets)
Wednesday, March 1, 2006

This topic is archived.


Back to support forum

Forum search