[xwiki-users] Bug on the sortable filterable table javascript.
Dear all, I found a bug on the sortable filterable table : i have different options (PO done and done) in a table cell. When using the filterable option, the done option do not appear in the selection. I went searching in the tablefilterNsort.js file, and it seems it comes from the PopulateOptions method, and more particularly from the search method in the celldata check : if(OptArray.toString().toUpperCase().search(cell_data.toUpperCase()) == -1) // checks if celldata is already in array The method search returns the number of occurence of the searched parameter, in my case, it returns 1 for done, but i would like -1 (my option is different). I tried changing the test (if its different to -1, addind a test on the length), but did not found an answer. I think this is a quite serious matter, as this problem may be found quite often. Somebody had the same problem ? Somebody is a master of javascript (i am not unfortunately) and might help on this ? Best regards Jean. -- ---- Jean Couteau Code Lutin - http://www.codelutin.com 44 Bd des Pas Enchantés - 44230 St-Sébastien/Loire Tél : 02 40 50 29 28 - Fax : 09 59 92 29 28
Ok, i found a solution, it is ugly, and i hope it does not add problems elsewhere, but at least it works for me. Here it is (only the PopulateOptions method) : function PopulateOptions(id,cellIndex,ncells) /*==================================================== - populates select - adds only 1 occurence of a value =====================================================*/ { var t = document.getElementById(id); var start_row = getStartRow(id); var row = t.getElementsByTagName("tr"); var OptArray = new Array(); var optIndex = 0; // option index for(var k=start_row; k<row.length; k++) { var cell = getChildElms(row[k]).childNodes; var nchilds = cell.length; if(nchilds == ncells){// checks if row has exact cell # for(var j=0; j<nchilds; j++)// this loop retrieves cell data { if(cellIndex==j) { var cell_data = getCellText(cell[j]); var added = 0; if(OptArray.length==0) { added = 1; } else { added = 1; for(var i=0;i<OptArray.length;i++)//run through the option array { if(OptArray[i].toUpperCase() == cell_data.toUpperCase())// checks if celldata is already in array { added = 0; } }//for i }//else if(cell_data=="") { added=0; } if(added==1) // if celldata is not already in array { optIndex++; OptArray.push(cell_data); var currOpt = new Option(cell_data,cell_data,false,false); document.getElementById("flt"+cellIndex+"_"+id).options[optIndex] = currOpt; } }//if cellIndex==j }//for j }//if }//for k } With that, no problem if one option is a substring of an other one. Hope this helps other people too. Jean Couteau a écrit :
Dear all,
I found a bug on the sortable filterable table : i have different options (PO done and done) in a table cell. When using the filterable option, the done option do not appear in the selection.
I went searching in the tablefilterNsort.js file, and it seems it comes from the PopulateOptions method, and more particularly from the search method in the celldata check : if(OptArray.toString().toUpperCase().search(cell_data.toUpperCase()) == -1) // checks if celldata is already in array
The method search returns the number of occurence of the searched parameter, in my case, it returns 1 for done, but i would like -1 (my option is different). I tried changing the test (if its different to -1, addind a test on the length), but did not found an answer.
I think this is a quite serious matter, as this problem may be found quite often. Somebody had the same problem ? Somebody is a master of javascript (i am not unfortunately) and might help on this ?
Best regards
Jean.
-- ---- Jean Couteau Code Lutin - http://www.codelutin.com 44 Bd des Pas Enchantés - 44230 St-Sébastien/Loire Tél : 02 40 50 29 28 - Fax : 09 59 92 29 28
participants (1)
-
Jean Couteau