Sorting Repeats using JavaScript

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Sorting Repeats using JavaScript

Ryan Puddephatt

Hi all,

            I am trying to amend a sorting script to work with the <xforms:repeat>, but I’m having a few difficulties. I have noticed that the table has an empty row with class ‘xforms-repeat-begin-end’ at the beginning and end and also an empty row between each entry with ‘xforms-repeat-delimeter’ What are these used for? Do they require any special treatment? Would it be possible to just remove them?

 

Thanks

 

Ryan Puddephatt

Web Developer

TFX Group

1 Michaelson Square

Livingston

West Lothian

Scotand

EH54 7DP

 

* [hidden email]

( 01506 407 110

7  01506 407 108

 

 



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Sorting Repeats using JavaScript

Erik Bruchez
Administrator
Ryan,

 > I am trying to amend a sorting script to work with the
 > <xforms:repeat>, but I'm having a few difficulties. I have noticed
 > that the table has an empty row with class 'xforms-repeat-begin-end'
 > at the beginning and end and also an empty row between each entry
 > with 'xforms-repeat-delimeter' What are these used for? Do they
 > require any special treatment? Would it be possible to just remove
 > them?

I wouldn't go there, for several reasons:

1. Those delimiters are there so that the XForms engine can perform
    updates, insertions and deletions of repeated elements in the HTML
    DOM. Removing them will break XForms functionality in unexpected
    ways.

2. The format of the XHTML generated by the XForms engine may change
    over time, and relying on it may cause your application to break in
    the future.

3. One of the raisons d'etre of XForms is to reduce the need for
    Javascript ;-)

So I would strongly advise for now to use an XForm submission and
replace="instance" to perform your sorting. This is the portable
XForms-compliant way to do it.

Another solution, which would be a custom enhancement to the OPS
XForms engine, would be to implement optional built-in sorting for
repeated sections. But this would be a little project on its own.

-Erik



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: Sorting Repeats using JavaScript

Ryan Puddephatt
>Another solution, which would be a custom enhancement to the OPS
>XForms engine, would be to implement optional built-in sorting for
>repeated sections. But this would be a little project on its own.

Erik,
        I have now got the script working with Orbeon, which I've attached
for you to take a look at! It keeps all the hidden rows in place for XForms
to continue working, but allows really quick client side sorting on tables.
I've got it working for numbers and text at the moment. I believe it will
work with dates and currency!

If you want a reproducible example, I'll get one sorted for you, but it is
very simple to change and attach!

The code can be added by simple including the script file (which you'll need
to rename from sorttable.script to sorttable.js!) and adding the class
'sortable' to the table! The JavaScript does all the work for you

Its certainly a good addition for us, although I appreciate that it is very
dependant upon the function of the xforms:repeat, it would be quite easy to
change!

Thanks

Ryan Puddephatt
Web Developer
TFX Group
1 Michaelson Square
Livingston
West Lothian
Scotand
EH54 7DP
 
* [hidden email]
( 01506 407 110
7  01506 407 108
 
-----Original Message-----
From: Erik Bruchez [mailto:[hidden email]] On Behalf Of Erik Bruchez
Sent: 29 November 2005 13:18
To: [hidden email]
Subject: Re: [ops-users] Sorting Repeats using JavaScript

Ryan,

 > I am trying to amend a sorting script to work with the
 > <xforms:repeat>, but I'm having a few difficulties. I have noticed
 > that the table has an empty row with class 'xforms-repeat-begin-end'
 > at the beginning and end and also an empty row between each entry
 > with 'xforms-repeat-delimeter' What are these used for? Do they
 > require any special treatment? Would it be possible to just remove
 > them?

I wouldn't go there, for several reasons:

1. Those delimiters are there so that the XForms engine can perform
    updates, insertions and deletions of repeated elements in the HTML
    DOM. Removing them will break XForms functionality in unexpected
    ways.

2. The format of the XHTML generated by the XForms engine may change
    over time, and relying on it may cause your application to break in
    the future.

3. One of the raisons d'etre of XForms is to reduce the need for
    Javascript ;-)

So I would strongly advise for now to use an XForm submission and
replace="instance" to perform your sorting. This is the portable
XForms-compliant way to do it.

Another solution, which would be a custom enhancement to the OPS
XForms engine, would be to implement optional built-in sorting for
repeated sections. But this would be a little project on its own.

-Erik



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws

sorttable.script (11K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

RE: Sorting Repeats using JavaScript

Ryan Puddephatt
Hi all,
        I have been working on this to make it more full proof with Orbeon,
I've added a bit more code to the one I sent round earlier! I now have it
fully working apart from one area, the highlighting of the rows! After
moving them around it seems to like highlighting more that one row! When I
change the index of the repeat what functions would be run? How is the index
stored in the table? Would it be possible to update the index?

Thanks

Ryan Puddephatt
Web Developer
TFX Group
1 Michaelson Square
Livingston
West Lothian
Scotand
EH54 7DP
 
* [hidden email]
( 01506 407 110
7  01506 407 108
 

-----Original Message-----
From: Ryan Puddephatt [mailto:[hidden email]]
Sent: 29 November 2005 13:33
To: [hidden email]
Subject: RE: [ops-users] Sorting Repeats using JavaScript

>Another solution, which would be a custom enhancement to the OPS
>XForms engine, would be to implement optional built-in sorting for
>repeated sections. But this would be a little project on its own.

Erik,
        I have now got the script working with Orbeon, which I've attached
for you to take a look at! It keeps all the hidden rows in place for XForms
to continue working, but allows really quick client side sorting on tables.
I've got it working for numbers and text at the moment. I believe it will
work with dates and currency!

If you want a reproducible example, I'll get one sorted for you, but it is
very simple to change and attach!

The code can be added by simple including the script file (which you'll need
to rename from sorttable.script to sorttable.js!) and adding the class
'sortable' to the table! The JavaScript does all the work for you

Its certainly a good addition for us, although I appreciate that it is very
dependant upon the function of the xforms:repeat, it would be quite easy to
change!

Thanks

Ryan Puddephatt
Web Developer
TFX Group
1 Michaelson Square
Livingston
West Lothian
Scotand
EH54 7DP
 
* [hidden email]
( 01506 407 110
7  01506 407 108
 
-----Original Message-----
From: Erik Bruchez [mailto:[hidden email]] On Behalf Of Erik Bruchez
Sent: 29 November 2005 13:18
To: [hidden email]
Subject: Re: [ops-users] Sorting Repeats using JavaScript

Ryan,

 > I am trying to amend a sorting script to work with the
 > <xforms:repeat>, but I'm having a few difficulties. I have noticed
 > that the table has an empty row with class 'xforms-repeat-begin-end'
 > at the beginning and end and also an empty row between each entry
 > with 'xforms-repeat-delimeter' What are these used for? Do they
 > require any special treatment? Would it be possible to just remove
 > them?

I wouldn't go there, for several reasons:

1. Those delimiters are there so that the XForms engine can perform
    updates, insertions and deletions of repeated elements in the HTML
    DOM. Removing them will break XForms functionality in unexpected
    ways.

2. The format of the XHTML generated by the XForms engine may change
    over time, and relying on it may cause your application to break in
    the future.

3. One of the raisons d'etre of XForms is to reduce the need for
    Javascript ;-)

So I would strongly advise for now to use an XForm submission and
replace="instance" to perform your sorting. This is the portable
XForms-compliant way to do it.

Another solution, which would be a custom enhancement to the OPS
XForms engine, would be to implement optional built-in sorting for
repeated sections. But this would be a little project on its own.

-Erik





--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Sorting Repeats using JavaScript

Erik Bruchez
Administrator
Ryan,

Thanks for providing this! We will have to have a look at it. One
important aspect to consider is whether this strategy is architecturally
sound, because you are changing client-side data without telling the
XForms engine to update its state to reflect the change.

Alex should be able to comment on the subject of the index.

-Erik

Ryan Puddephatt wrote:

> Hi all,
> I have been working on this to make it more full proof with Orbeon,
> I've added a bit more code to the one I sent round earlier! I now have it
> fully working apart from one area, the highlighting of the rows! After
> moving them around it seems to like highlighting more that one row! When I
> change the index of the repeat what functions would be run? How is the index
> stored in the table? Would it be possible to update the index?
>
> Thanks
>
> Ryan Puddephatt
> Web Developer
> TFX Group
> 1 Michaelson Square
> Livingston
> West Lothian
> Scotand
> EH54 7DP
>  
> * [hidden email]
> ( 01506 407 110
> 7  01506 407 108
>  
>
> -----Original Message-----
> From: Ryan Puddephatt [mailto:[hidden email]]
> Sent: 29 November 2005 13:33
> To: [hidden email]
> Subject: RE: [ops-users] Sorting Repeats using JavaScript
>
>
>>Another solution, which would be a custom enhancement to the OPS
>>XForms engine, would be to implement optional built-in sorting for
>>repeated sections. But this would be a little project on its own.
>
>
> Erik,
> I have now got the script working with Orbeon, which I've attached
> for you to take a look at! It keeps all the hidden rows in place for XForms
> to continue working, but allows really quick client side sorting on tables.
> I've got it working for numbers and text at the moment. I believe it will
> work with dates and currency!
>
> If you want a reproducible example, I'll get one sorted for you, but it is
> very simple to change and attach!
>
> The code can be added by simple including the script file (which you'll need
> to rename from sorttable.script to sorttable.js!) and adding the class
> 'sortable' to the table! The JavaScript does all the work for you
>
> Its certainly a good addition for us, although I appreciate that it is very
> dependant upon the function of the xforms:repeat, it would be quite easy to
> change!
>
> Thanks
>
> Ryan Puddephatt
> Web Developer
> TFX Group
> 1 Michaelson Square
> Livingston
> West Lothian
> Scotand
> EH54 7DP
>  
> * [hidden email]
> ( 01506 407 110
> 7  01506 407 108
>  
> -----Original Message-----
> From: Erik Bruchez [mailto:[hidden email]] On Behalf Of Erik Bruchez
> Sent: 29 November 2005 13:18
> To: [hidden email]
> Subject: Re: [ops-users] Sorting Repeats using JavaScript
>
> Ryan,
>
>  > I am trying to amend a sorting script to work with the
>  > <xforms:repeat>, but I'm having a few difficulties. I have noticed
>  > that the table has an empty row with class 'xforms-repeat-begin-end'
>  > at the beginning and end and also an empty row between each entry
>  > with 'xforms-repeat-delimeter' What are these used for? Do they
>  > require any special treatment? Would it be possible to just remove
>  > them?
>
> I wouldn't go there, for several reasons:
>
> 1. Those delimiters are there so that the XForms engine can perform
>     updates, insertions and deletions of repeated elements in the HTML
>     DOM. Removing them will break XForms functionality in unexpected
>     ways.
>
> 2. The format of the XHTML generated by the XForms engine may change
>     over time, and relying on it may cause your application to break in
>     the future.
>
> 3. One of the raisons d'etre of XForms is to reduce the need for
>     Javascript ;-)
>
> So I would strongly advise for now to use an XForm submission and
> replace="instance" to perform your sorting. This is the portable
> XForms-compliant way to do it.
>
> Another solution, which would be a custom enhancement to the OPS
> XForms engine, would be to implement optional built-in sorting for
> repeated sections. But this would be a little project on its own.
>
> -Erik
>
>
>
>
>
> ------------------------------------------------------------------------
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: Sorting Repeats using JavaScript

Ryan Puddephatt
Thanks Eric, I have it working here quite nicely, I know more needs to be
done to get the XForms engine to work more comfortably with it, but I would
be willing to put in the dev time to get it working as I feel it would be a
useful feature.

I just need some pointers in the right direction

Thanks for taking a look!

Ryan Puddephatt
Web Developer
TFX Group
1 Michaelson Square
Livingston
West Lothian
Scotand
EH54 7DP
 
* [hidden email]
( 01506 407 110
7  01506 407 108
 

-----Original Message-----
From: Erik Bruchez [mailto:[hidden email]] On Behalf Of Erik Bruchez
Sent: 30 November 2005 14:11
To: [hidden email]
Subject: Re: [ops-users] Sorting Repeats using JavaScript

Ryan,

Thanks for providing this! We will have to have a look at it. One
important aspect to consider is whether this strategy is architecturally
sound, because you are changing client-side data without telling the
XForms engine to update its state to reflect the change.

Alex should be able to comment on the subject of the index.

-Erik

Ryan Puddephatt wrote:
> Hi all,
> I have been working on this to make it more full proof with Orbeon,
> I've added a bit more code to the one I sent round earlier! I now have it
> fully working apart from one area, the highlighting of the rows! After
> moving them around it seems to like highlighting more that one row! When I
> change the index of the repeat what functions would be run? How is the
index

> stored in the table? Would it be possible to update the index?
>
> Thanks
>
> Ryan Puddephatt
> Web Developer
> TFX Group
> 1 Michaelson Square
> Livingston
> West Lothian
> Scotand
> EH54 7DP
>  
> * [hidden email]
> ( 01506 407 110
> 7  01506 407 108
>  
>
> -----Original Message-----
> From: Ryan Puddephatt [mailto:[hidden email]]
> Sent: 29 November 2005 13:33
> To: [hidden email]
> Subject: RE: [ops-users] Sorting Repeats using JavaScript
>
>
>>Another solution, which would be a custom enhancement to the OPS
>>XForms engine, would be to implement optional built-in sorting for
>>repeated sections. But this would be a little project on its own.
>
>
> Erik,
> I have now got the script working with Orbeon, which I've attached
> for you to take a look at! It keeps all the hidden rows in place for
XForms
> to continue working, but allows really quick client side sorting on
tables.
> I've got it working for numbers and text at the moment. I believe it will
> work with dates and currency!
>
> If you want a reproducible example, I'll get one sorted for you, but it is
> very simple to change and attach!
>
> The code can be added by simple including the script file (which you'll
need
> to rename from sorttable.script to sorttable.js!) and adding the class
> 'sortable' to the table! The JavaScript does all the work for you
>
> Its certainly a good addition for us, although I appreciate that it is
very
> dependant upon the function of the xforms:repeat, it would be quite easy
to

> change!
>
> Thanks
>
> Ryan Puddephatt
> Web Developer
> TFX Group
> 1 Michaelson Square
> Livingston
> West Lothian
> Scotand
> EH54 7DP
>  
> * [hidden email]
> ( 01506 407 110
> 7  01506 407 108
>  
> -----Original Message-----
> From: Erik Bruchez [mailto:[hidden email]] On Behalf Of Erik Bruchez
> Sent: 29 November 2005 13:18
> To: [hidden email]
> Subject: Re: [ops-users] Sorting Repeats using JavaScript
>
> Ryan,
>
>  > I am trying to amend a sorting script to work with the
>  > <xforms:repeat>, but I'm having a few difficulties. I have noticed
>  > that the table has an empty row with class 'xforms-repeat-begin-end'
>  > at the beginning and end and also an empty row between each entry
>  > with 'xforms-repeat-delimeter' What are these used for? Do they
>  > require any special treatment? Would it be possible to just remove
>  > them?
>
> I wouldn't go there, for several reasons:
>
> 1. Those delimiters are there so that the XForms engine can perform
>     updates, insertions and deletions of repeated elements in the HTML
>     DOM. Removing them will break XForms functionality in unexpected
>     ways.
>
> 2. The format of the XHTML generated by the XForms engine may change
>     over time, and relying on it may cause your application to break in
>     the future.
>
> 3. One of the raisons d'etre of XForms is to reduce the need for
>     Javascript ;-)
>
> So I would strongly advise for now to use an XForm submission and
> replace="instance" to perform your sorting. This is the portable
> XForms-compliant way to do it.
>
> Another solution, which would be a custom enhancement to the OPS
> XForms engine, would be to implement optional built-in sorting for
> repeated sections. But this would be a little project on its own.
>
> -Erik
>
>
>
>
>
> ------------------------------------------------------------------------
>
>
> --
> You receive this message as a subscriber of the [hidden email]
mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws






--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Sorting Repeats using JavaScript

Alessandro  Vernet
Administrator
In reply to this post by Ryan Puddephatt
On 11/30/05, Ryan Puddephatt <[hidden email]> wrote:
>         I have been working on this to make it more full proof with Orbeon,
> I've added a bit more code to the one I sent round earlier! I now have it
> fully working apart from one area, the highlighting of the rows! After
> moving them around it seems to like highlighting more that one row! When I
> change the index of the repeat what functions would be run? How is the index
> stored in the table? Would it be possible to update the index?

Hi Ryan,

One way to change the index would be to dispatch a "focus" event on a
control inside the iteration you want to change the index to. This
will simulate a click from the user on that control, issue a request
to the XForms server, and do everything that needs to be done when the
index changes (there can be recalculations, etc).

To do this from JavaScript, have a look at the function
xformsDispatchEvent() in xforms.js which dispatches an HTML event in a
portable way (so far working on IE and Firefox).

Alex
--
Blog (XML, Web apps, Open Source): http://www.orbeon.com/blog/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet