Hey Matt,

 I changed the code accordingy, but I'm getting the any cols, it says length=0,  and its passing undefined to setIndicator(), what could be the problem.

var cols = table.getElementsByTagName("th");

here is the code:

function addSortIndicator()

{

var table = document.getElementsByTagName("table")[0];

var cols = table.getElementsByTagName("th");

var sort = "<%=request.getParameter("sort")%>";

var order = "<%=request.getParameter("order")%>";

alert("cols length:"+cols.length);

alert("table:"+table);

alert("cols:"+cols);

alert("Sort:"+sort);

alert("Order:"+order);

if (order != "null")

{

if (order == "dec")

{

order = "desc";

}

}

if(sort != "null")

{

alert("calling setIndicator:"+cols[sort])

setIndicator(cols[sort], order);

}

}

window.>

function setIndicator(e, order)

{

e.className = "sorted";

var indicator = document.createElement("img");

alert("Inside setIndicator:indicator:"+indicator);

indicator.setAttribute("src", "<%=request.getContextPath()%>/images/"+order+".gif");

indicator.setAttribute("width", "9");

indicator.setAttribute("height", "10");

indicator.setAttribute("alt", (order == "asc") ? "Ascending" : "Descending");

indicator.className = "sortIndicator";

e.appendChild(indicator);

}

</script>

 

 

 



Matt Raible <[EMAIL PROTECTED]> wrote:
This is JSTL code - http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html

You could also use:

var sort = "<%=request.getParameter("sort")%>";

However, this would return:

var sort = "null"

when no parameter was present - so you'd have to modify the _javascript_
accordingly.

HTH,

Matt

> the following code doesn't work for me, any i deas?
>
> var sort = "";
>
> [EMAIL PROTECTED] wrote:
> Just an other question: for which taglib does refer the tag in
> the following code?
>
> ";
>
> Thanks,
> Didier.
> _______________________
> Didier Dubois
> dotBase solutions informatiques SA
> 25, route des Acacias
> CH - 1227 Gen�ve
>
> Tel. +41 22 301 07 07
> Fax. +41 22 301 07 08
>
> |---------+------------------------------------------->
> | | "Matt Raible" |
> | | |
> | | Sent by: |
> | | [EMAIL PROTECTED]|
> | | ceforge.net |
> | | |
> | | |
> | | 05/06/2003 12:50 PM |
> | | |
> |---------+------------------------------------------->
>
>-------------------------------------------------------------------------------------------------|
> | |
> | To: |
> | cc: |
> | Subject: RE: [displaytag-user] Sorting with the Display Tag |
>
>-------------------------------------------------------------------------------------------------|
>
> Unless you have a dynamic number of tables on your page, you can simply
> reference it by index [0]. If you *really need* an id, please submit
> a bug or a patch to add this.
>
> Thanks,
>
> Matt
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On
> > Behalf Of [EMAIL PROTECTED]
> > Sent: Thursday, June 05, 2003 4:33 AM
> > To: Matt Raible
> > Cc: [EMAIL PROTECTED];
> > [EMAIL PROTECTED]
> > Subject: Re: [displaytag-user] Sorting with the Display Tag
> >
> >
> >
> > Excellent. But how can we specify an ID for the display table ???
> >
> > On the code var table = document.getElementsByTagName("table")[0];
> > U assume, the 1st table of the document. But in "real-life"
> > cases, the display is not the only HTML table
> >
> > Thanks,
> > Didier.
> > _______________________
> > Didier Dubois
> > dotBase solutions informatiques SA
> > 25, route des Acacias
> > CH - 1227 Gen�ve
> >
> > Tel. +41 22 301 07 07
> > Fax. +41 22 301 07 08
> >
> >
> > |---------+------------------------------------------->
> > | | "Matt Raible" |
> > | | |
> > | | Sent by: |
> > | | [EMAIL PROTECTED]|
> > | | ceforge.net |
> > | | |
> > | | |
> > | | 04/06/2003 09:04 PM |
> > | | |
> > |---------+------------------------------------------->
> >
> > >-------------------------------------------------------------
> > ------------------------------------|
> > |
> > |
> > | To:
> > |
> > | cc:
> > |
> > | Subject: Re: [displaytag-user] Sorting with the
> > Display Tag |
> >
> > >-------------------------------------------------------------
> > ------------------------------------|
> >
> >
> >
> >
> > > First of all, I would like to congratulate the developers. This
> > > display tag is great. I am building a table using the library that
> > > allows users to sort columns. I would like to indicate
> > which column
> > > is currently being sorted and in which direction by displaying an
> > > arrow next to the column title like Hotmail, Yahoo Mail, etc.
> >
> > > How can I accomplish this with the Display Tag Library?
> >
> > This is currently not a feature in the tag, but I whipped up
> > a little _javascript_ and CSS to make this possible:
> >
> > CSS
> > ---------
> >
> > th.sorted {
> > background: #A9A9A9 !important;
> > color: #000000 !important;
> > cursor: pointer !important; /* IE 5.5 non-compliant workaround */
> > cursor: hand !important;
> > padding-left: 3px;
> > }
> >
> > img.sortIndicator {
> > margin-left: 3px;
> > }
> >
> > _javascript_
> > ------------
> > function addSortIndicator() {
> > var table = document.getElementsByTagName("table")[0];
> > var cols = table.getElementsByTagName("th");
> > var sort = "";
> > var order = "";
> > // my own little hack to set the right name for the image
> > if (order == "dec") {
> > order = "desc";
> > }
> > if (sort == "") {
> > setIndicator(cols[3], "desc"); // 4th column is
> > sorted in query
> > } else {
> > setIndicator(cols[sort], order);
> > }
> > }
> >
> > window.>> >
> > function setIndicator(e, order) {
> > e.className = "sorted";
> > var indicator = document.createElement("img");
> > indicator.setAttribute("src",
> > "/images/"+order+".gif");
> > indicator.setAttribute("width", "9");
> > indicator.setAttribute("height", "10");
> > indicator.setAttribute("alt", (order == "asc") ?
> > "Ascending" : "Descending");
> > indicator.className = "sortIndicator";
> > e.appendChild(indicator);
> > }
> >
> > You can download the images I used from:
> >
> http://raibledesigns.com/demos/images/
>
> This works great for me - thanks for the idea!
>
> Matt
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Etnus, makers of TotalView, The best
> thread debugger on the planet. Designed with thread debugging
> features you've never dreamed of, try TotalView 6 free at www.etnus.com.
> _______________________________________________
> displaytag-user mailing list [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/displaytag-user
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Etnus, makers of TotalView, The best
> thread debugger on the planet. Designed with thread debugging
> features you've never dreamed of, try TotalView 6 free at www.etnus.com.
> _______________________________________________
> displaytag-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/displaytag-user
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Etnus, makers of TotalView, The best
> thread debugger on the planet. Designed with thread debugging
> features you've never dreamed of, try TotalView 6 free at www.etnus.com.
> _______________________________________________
> displaytag-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/displaytag-user
>
> ---------------------------------
> Do you Yahoo!?
> Free online calendar with sync to Outlook(TM).


-- Matt Raible, Raible Designs, Morrison CO US
-- Tel: +1 303 979-5340
-- Mob: +1 720 560-8460
-- Fax: +1 508 256-6471
-- Web: http://www.raibledesigns.com


Do you Yahoo!?
Free online calendar with sync to Outlook(TM).

Reply via email to