DHTMLgrid & Sorting

I have an DHTMLgrid which is loaded through an XML file.

The first column is a link. These links can be in the form:



the fileName can be locationondisk/files/filename or locationondisk/filename

When is sort this column it makes a sortation not on the documentname, but on the resulting URLS. therefore the documentNames are not sorter correcty.

How can i get the sorting of this colum get to sort on the documentnames which i see in the column?

While sorting grid takes getValue() from the cell and filter grid depending on this value. getValue() method from the “link” eXcell type will return string with a full path to your file. To change that behaviour you can implement custom eXcell type. Please see more information here dhtmlx.com/docs/products/dhtmlxG … #grid_cexc

I’ve tried using an Excell type, using a script, but with no good results. This is the code i use:

            function eXcell_AOtext(cell){             //excell name is defined here
                if (cell){                                  //default pattern, just copy it
                    this.cell = cell;
                    this.grid = this.cell.parentNode.grid;
                this.edit = function(){}            //read-only cell doesn’t have edit method
                this.isDisabled = function(){ return true; }      // the cell is read-only, that’s why it is always in the disabled state
                var temp = val.split(“^”);
                name  = temp[0];
                url  = temp[1];
                target  = temp[2];
                urlNew = ‘javascript:openDocument("’+url+‘");’;
                    this.setCValue(“<a name='”+name+“‘href=’”+urlNew+“'>”+name+“”,val);
            eXcell_AOtext.prototype = new eXcell;    // nest all other methods from base class

See also attachment what happens

Can you provide a code sample for me?


You didn’t define getValue() method for your excell.

Actually get use a ready link excell. dhtmlxgrid_excell_link.js, but in this case you should redefine its getValue() method as you need. Currently it returns following value:


It means - link_title^url.

You need to return an url or part of it (this.cell.firstChild.getAttribute(“href”) ) from getValue method

I see what you mean, but i think these custom excells have more to do with the presenation of the link within the cell.
The problem i have is with the sorting of the column. It now sorts on the Link_url string. I want to have it sorting on the Link_title name string. How do i do that?
Thanks in advance.

Sorting routine use getValue method of excell to get text by which row will be sorted.
So you can create a custom getter , which will return any necessary value.

return this.cell.getAttribute(“name”); //or any other value

thanks, this helped me a lot!