3.2.0

Sorting columns that contain anchors

Hi all,

I've tripped with this problem (the column wasn't sorting at all), and I can think of just 2 things:

1) Since I'm not using the anchor template (just putting the <a> tags along with the data), maybe it's already contemplated

2) It's not, and I think you should consider this for v2... it's only about stripping the text if the cell contains tags (any tags), and using that to sort.

Thanks, and great work!
Federico Halperin
February 7,
Frederico,
In V2 you can simply set up a link template for a column:

// set cell to have link for drill to detail page, or website home

obj.setCellTemplate(new AW.Templates.Link, 0); // make link template for first col (c0)

// set the Target like this:
obj.getCellTemplate(0).setAttribute("target", "_blank"); //col 1 (c0) always in new window

// set the link to URL to a col of data in the DATA set: myData[r][5] contains the URLs here.
obj.setCellLink(function(c, r){ return myData[r][5]; }, 1); // col 6(c5) of mydata is Link list for Col 2(c1)!

/* so it seems a same to defeat all this with an anchor in the cell.

I have a full example if you need it posted....
G. Cayman
February 7,
Thanks G, I'll try it and then post feedback...

Still, as I said in the previous post, I think (as a suggestion for Alex) that making the sort algorithm intelligent enough to strip *any* tags that may be found in the cell data would be a clever thing... because any of those can be found depending on the programmer needs (e.g. <span> for tooltips, <b>, <i>, <u> for text formatting, and so on)
Federico Halperin
February 7,
Federico,

it is already implemented in 2.0 - the AW.Formats.HTML class strips all html tags in textToValue() method so the sorting is done on actual content.

If you inject HTML into cell content - use AW.Formats.HTML as cell format for correct sorting.
Alex (ActiveWidgets)
February 8,
I don't quite understand the use here of AW.Formats.HTML?

It seems that, text cells sort correctly in V2.0 with OR without this formating set. That is I can surround any text cell with almost any HTML, including an anchor tag and it still sorts correctly.

Could someone explain the exact implications of what Alex says above?
thanks
-g


G. Cayman
February 9,
Alex,
Since you seem to be in the "philosophy of the system mind set" tonight, could you comment on the above discussion? All my experiments and tests point to the fact that AW.Formats.HTML seems to be the default. That is, if I do not set to Fomrats.HTML it seems to strip and sort correctly anyway.

I'd like to know from the master, for my Demo documentation?

What exactly is the philosophy here?

-geoff
G Cayman
February 10,
If you inject the same markup into the cells (i.e. all tags and attributes are the same) than the sort order will be correct because only text content will differ. However if you inject <a href="..."> tags with different URLs then the sort will be done according to URLs unless you use AW.Formats.HTML to strip out HTML tags in textToValue() transformation (for sorting).

The dataToText() method is also slightly different - AW.Formats.HTML does not do any transformation assuming the content is already HTML while AW.Formats.String thinks that incoming data is String and properly escapes HTML control characters (<, >, &, ", space).
Alex (ActiveWidgets)
February 10,
Docs coming soon...
Alex (ActiveWidgets)
February 10,
alex,
this is NOT the default behavior I'm seeing, If I put <u> around one, <i> around another, and <b> another...

it defaulty still sorts correctly by the enclosed text!

with out any setting?

what am i missing?!!!


G Cayman
February 10,
Oops, very sorry for the confusion - in fact most of what I said above is wrong :-(((

Let me try to correct the damage -

textToValue() transformation strips html tags in case you use AW.Formats.String, AW.Formats.HTML or don't use format object at all. In all of those cases the sorting should be correct. There is just one small difference in comparator function used - AW.Formats.String and AW.Formats.HTML use String.localeCompare() method which is presumably case insensitive while if you are not using formatting object the default comparator uses > or < which is just hex value of the first characters.

The actual difference between AW.Formats.String and AW.Formats.HTML is in dataToText() method. AW.Formats.String does encode control characters (<, >, &, ") while AW.Formats.HTML is not.

Again, sorry for the confusion and going back to writing proper docs...
:-(
Alex (ActiveWidgets)
February 11,

This topic is archived.

See also:


Back to support forum