From: Thyamad c. <th...@us...> - 2006-01-29 14:22:43
|
Update of /cvsroot/thyapi/thyapi/thywidgets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11150/thywidgets Modified Files: thygrid.js thylistbox_ie.js Log Message: Commiting file additions and modification from SVN revision 2730 to 2731... Changes made by vinicius on 2006-01-29 16:29:22 +0100 (Sun, 29 Jan 2006) corresponding to SVN revision 2731 with message: enhancements in thylistbox_ie Index: thylistbox_ie.js =================================================================== RCS file: /cvsroot/thyapi/thyapi/thywidgets/thylistbox_ie.js,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** thylistbox_ie.js 28 Jan 2006 15:12:48 -0000 1.2 --- thylistbox_ie.js 29 Jan 2006 14:22:05 -0000 1.3 *************** *** 41,45 **** this.addCSSClass('thyListBox'); - /*this.contents.addCSSClass(this.name); */ this.onPreCreate(this.preInitThyListBox); --- 41,44 ---- *************** *** 265,269 **** for (i in selarr) { ! selectedNames.push(selarr[i].n); } return selectedNames; --- 264,268 ---- for (i in selarr) { ! selectedNames.push(selarr[i].t); } return selectedNames; *************** *** 304,308 **** retrow = new thyCollection(); retrow.add(selarr[i].v); ! retrow.add(selarr[i].n); retcol.add(retrow); } --- 303,307 ---- retrow = new thyCollection(); retrow.add(selarr[i].v); ! retrow.add(selarr[i].t); retcol.add(retrow); } *************** *** 312,315 **** --- 311,350 ---- p.getSelectedRows = p.getSelected; + /** + * Method: getAllRows + * + * Return a <thyCollection> with other <thyCollections> containing + * the elements of the entire <thyGrid> + * + */ + p.getAllRows = function() + { + var selopt = this.contents.elm.childNodes[0].options, i; + var retcol = new thyCollection(), retrow; + + for (i=0;i<selopt.length;i++) + { + retrow = new thyCollection(); + retrow.add(selopt[i].value); + retrow.add(selopt[i].text); + retcol.add(retrow); + } + return retcol; + } + + /** + * Method: getRowsCount + * + * Returns the number of rows in ListBox + * + */ + p.getRowsCount = function() + { + return this.contents.elm.childNodes[0].options.length; + } + + p.getRow = function() + { + } /** *************** *** 337,341 **** /** ! * Method: search * * Searches for a specified string inside values column --- 372,376 ---- /** ! * Method: searchColumn * * Searches for a specified string inside values column *************** *** 344,359 **** * * str - The string to be searched for * * Returns: the row index */ ! p.search = function (str) { var selopt = this.contents.elm.childNodes[0].options, i; for (i=0;i<selopt.length;i++) { ! if (selopt[i].value.indexOf(str) != -1) { ! return i; } } --- 379,431 ---- * * str - The string to be searched for + * col - The column index + * pos - position desired of match. If not specified search for matches in any position * * Returns: the row index */ ! p.searchColumn = function (str,col,pos) { + var typ; + if (col == 0 || col == null) { typ = 'value'; } + else { typ = 'text'; } + var selopt = this.contents.elm.childNodes[0].options, i; for (i=0;i<selopt.length;i++) { ! if (pos == null && selopt[i][typ].indexOf(str) != -1) { return i; } ! else if (pos != null && selopt[i][typ].indexOf(str) == pos) { return i; } ! } ! } ! ! /** ! * Method: search ! * ! * Searches for a specified string inside values column ! * ! * Parameter: ! * ! * str - The string to be searched for ! * ! * Returns: the row index ! */ ! p.search = function (str) ! { ! return this.searchColumn(str,0); ! } ! ! p.removeSelectedRows = function() ! { ! var selopt = this.contents.elm.childNodes[0].options, i; ! ! for (i=0; i<selopt.length;) ! { ! if (selopt[i].selected) ! { ! selopt[i] = null; ! } ! else { ! i++; } } *************** *** 363,366 **** --- 435,463 ---- + /** + * Method: sweepOutAll + * + * Sweeps out all the selected values and indexes, as well as the content + * + * The format of output object can be used as populate data for this same + * component + */ + p.sweepOutAll = function() + { + var selopt = this.contents.elm.childNodes[0].options, i, contentRows = [ ]; + + for (i=0; i<selopt.length;i++) + { + contentRows.push([selopt[i].value, selopt[i].text]); + } + + var data = { + selectedValues: this.getSelectedValues(), + rows: contentRows + }; + + return data; + } + /*************************************************************************\ * Group: Private Methods * *************** *** 437,481 **** */ p._populateContents = function (data) ! {/* ! var i, j, row, cell; ! ! if (!data.selectedValues || data.rows) ! { ! var rows; ! if (data.rows) rows = data.rows; ! else rows = data; ! ! this.cleanUp(); ! ! for (i = 0; i<rows.length; i++) ! { ! if (typeof(rows[i]) != 'object') rows[i] = [rows[i]]; ! row = new thyCollection('Row'+i); ! ! for (j=0; j<rows[i].length; j++) ! { ! row.add(rows[i][j],'Cell'+i+j); ! } ! this.appendRow(row); ! } ! } ! ! if (data.selectedValues) ! { ! var values = data.selectedValues; ! var nValues = data.selectedValues.length; ! var nRows = this.getRowsCount(); ! ! for (i=0; i<nValues; i++) ! { ! for (j=0; j<nRows; j++) ! { ! if (this.getRowElement(j).getCellElement(0).sweepOut() == values[i]) ! this.getRowElement(j).select(); ! } ! } ! }*/ ! ! if (typeof(data) == 'number') { --- 534,538 ---- */ p._populateContents = function (data) ! { if (typeof(data) == 'number') { *************** *** 618,622 **** { if (optlist[selvalues[j]]) { optlist[selvalues[j]].selected = true; } - else { optlist[selvalues[j]].selected = false; } } } --- 675,678 ---- Index: thygrid.js =================================================================== RCS file: /cvsroot/thyapi/thyapi/thywidgets/thygrid.js,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** thygrid.js 20 Jan 2006 01:26:12 -0000 1.9 --- thygrid.js 29 Jan 2006 14:22:05 -0000 1.10 *************** *** 73,77 **** this.gridContents = new thyGridContents(name+'_contents_table'); - this.rows = new thyVisualCollection(this.name+'_rowsCollection', this.gridContents); this.rowClasses = new thyCollection(); --- 73,76 ---- *************** *** 287,294 **** --- 286,297 ---- * Searches for a specified string in the specified column * + * This search returns the index of the rows that matches with the + * specified string, being this string the whole content or a substring + * * Parameters: * * str - The string to be searched for * col - The column index + * pos - position desired of match. If not specified search for matches in any position * * Returns: *************** *** 297,301 **** * */ ! p.searchColumn = function (str, col) { var i,content,cell,nRows = this.rows.getElementsCount(); --- 300,304 ---- * */ ! p.searchColumn = function (str, col, pos) { var i,content,cell,nRows = this.rows.getElementsCount(); *************** *** 304,308 **** { cell = this.rows.getElementByIndex(i).getCell(col).toString(); ! if (cell.indexOf(str) != -1) return i-1; } } --- 307,312 ---- { cell = this.rows.getElementByIndex(i).getCell(col).toString(); ! if (pos != null && cell.indexOf(str) == pos) { return i-1; } ! else if (pos == null && cell.indexOf(str) != -1) { return i-1; } } } |