Dynamic table filtering/sorting

53 views
Skip to first unread message

imbibinebe

unread,
Mar 7, 2012, 5:10:34 PM3/7/12
to JavaScript Templates Engine PURE
Hi,
I use PURE to build a complex table only from a JSON data object. I
use the 'pos' property to access data array keys and set these keys as
my column names (really useful !)
Now, i am trying to do dynamic filtering and sorting on this table.
For each column i have an input inside the <th> which allows to sort
and filter table rows (depending on data values)
But, i also have a special input on the left of the table which allows
to sort and filter table colums (depending on data keys)
My problem is that PURE doesn't allow to sort/filter objects (only
arrays). This prevents me to sort columns because their names depend
on data keys (not values).

Example:
if my data is:

{
'users' : [
{ 'key1' : 'value11' , 'key2' : 'value12' },
{ 'key2' : 'value21' , 'key2' : 'value22' }
]
}

the table looks like:

[ column input filter ] [ key1 ]
[ key2 ]
[ row1 input filter ][ row2 input
filter ]
[ value11 ]
[ value12 ]
[ value21 ]
[ value22 ]

I wonder if sort/filter on objects could be a PURE feature or if it is
impossible ? If not, does anyone know an other method to do this kind
of thing ?

Anyway, thank you so much for this great templating engine. It's a
real pleasure to use it

imbibinebe

unread,
Mar 7, 2012, 5:15:46 PM3/7/12
to JavaScript Templates Engine PURE
Hi,
I use PURE to build a complex table only from a JSON data object. I
use the 'pos' property to access data array keys and set these keys as
my column names (really useful !)
Now, i am trying to do dynamic filtering and sorting on this table.
For each column i have an input inside the <th> which allows to sort
and filter table rows (depending on data values)
But, i also have a special input on the left of the table which allows
to sort and filter table colums (depending on data keys)
My problem is that PURE doesn't allow to sort/filter objects (only
arrays). This prevents me to sort columns because their names depend
on data keys (not values).
sorry the example was not lisible so
Example again:
if my data is:

{
'users' : [
{ 'key1' : 'value11' , 'key2' : 'value12' },
{ 'key2' : 'value21' , 'key2' : 'value22' }
]
}

the table looks like:

[ col filter ] [ key1 ][ key2 ]
[ r1 filter ][ r2 filter ]
[ value11 ][ value12 ]
[ value21 ][ value22 ]

imbibinebe

unread,
Mar 7, 2012, 6:21:54 PM3/7/12
to JavaScript Templates Engine PURE
I have to notice that filter feature works perfectly on objects as
well. So, I only have a problem with sorting :)

Mic (BeeBole)

unread,
Mar 8, 2012, 3:05:41 AM3/8/12
to JavaScript Templates Engine PURE
You can't sort an object and browsers may take the list in different
order.
If you want to sort you have to preprocess your object to an array.

imbibinebe

unread,
Mar 9, 2012, 1:04:57 PM3/9/12
to JavaScript Templates Engine PURE
Ok thanks Mic !
Anyway it was not an important feature
Reply all
Reply to author
Forward
0 new messages