//make new row & cell to add layer info to trow = document.createElement('tr'); tcell = document.createElement('td'); //apply alternating style to the row - rowodd and roweven are classes in a CSS file with different background colors so the table has alternating row colors //NOTE - IE has issues w/ setting class have to work around by using non-standard className //see http://webbugtrack.blogspot.com/2007/08/bug-242-setattribute-doesnt-always-work.html if (rowcount % 2 == 0) { if (dojo.isIE) {trow.setAttribute("className","rowodd"); } else { trow.setAttribute("class", "rowodd"); } } else { if (dojo.isIE) { trow.setAttribute("className", "roweven"); } else { trow.setAttribute("class", "roweven"); } } //use data from the featureset attributes to fill the innerHTML of the tcell here..... //tcell.innerHTML = "name: " + attribs[NAME] ; trow.appendChild(tcell); //now append that row to a tablebody - in this case one that already exists.. dojo.byId('tblbody').appendChild(trow); //example of inserting above the existing bottom row instead of appending.. //dojo.byId('tblbody').insertBefore(trow,dojo.byId('rowBtmRow')); //increment rowstyle counter rowcount += 1;
sortlist = []; for (var i = 0, il = results.length; i < il; i++) { result = results; attribs = result.feature.attributes; sortlist = new Array(2); sortlist[0] = attribs.PIN; //which ever field you want to sort on sortlist[1] = attribs; } sortlist.sort(numbersort); //now run your existing for loop but at the top reset attribs = sortlist[1] for (var i = 0, il = results.length; i < il; i++) { attribs = sortlist[1]; if (attribs.Active === "N") { s.push("<tr style=\"background-color:#F28282;\"><td nowrap><font size=2.5> " + attribs.Full_Address + "</font></td><td nowrap><font size=2.5>" + attribs.GIS_Key + "</font></td><td nowrap><font size=2.5>" + attribs.PIN + "</font></td><td nowrap><font size=2.5>" + attribs.Owner_Name + "</font></td><td nowrap><font size=2.5>" + attribs.Owner_Address + "</font></td><td nowrap><font size=2.5>" + attribs.Owner_City + "</font></td><td nowrap><font size=2.5>" + attribs.Owner_State + "</font></td><td nowrap><font size=2.5>" + attribs.Owner_ZIP + "</font></td><td nowrap><font size=2.5>" + attribs.Owner_Date + "</font></td><td nowrap><font size=2.5>" + attribs.Owner_Update + "</font></td><td nowrap><font size=2.5>" + attribs.Occupant_Name + "</font></td><td nowrap><font size=2.5>" + attribs.Occ_Phone1 + "</font></td><td nowrap><font size=2.5>" + attribs.Occ_Phone2 + "</font></td><td nowrap><font size=2.5>" + attribs.Village + "</font></td><td nowrap><font size=2.5>" + attribs.Active + "</font></td></tr>"); } else if (attribs.Village === "N") { s.push("<tr style=\"background-color:#BDBDBD;\"><td nowrap><font size=2.5> " + attribs.Full_Address + "</font></td><td nowrap><font size=2.5>" + attribs.GIS_Key + "</font></td><td nowrap><font size=2.5>" + attribs.PIN + "</font></td><td nowrap><font size=2.5>" + attribs.Owner_Name + "</font></td><td nowrap><font size=2.5>" + attribs.Owner_Address + "</font></td><td nowrap><font size=2.5>" + attribs.Owner_City + "</font></td><td nowrap><font size=2.5>" + attribs.Owner_State + "</font></td><td nowrap><font size=2.5>" + attribs.Owner_ZIP + "</font></td><td nowrap><font size=2.5>" + attribs.Owner_Date + "</font></td><td nowrap><font size=2.5>" + attribs.Owner_Update + "</font></td><td nowrap><font size=2.5>" + attribs.Occupant_Name + "</font></td><td nowrap><font size=2.5>" + attribs.Occ_Phone1 + "</font></td><td nowrap><font size=2.5>" + attribs.Occ_Phone2 + "</font></td><td nowrap><font size=2.5>" + attribs.Village + "</font></td><td nowrap><font size=2.5>" + attribs.Active + "</font></td></tr>"); } else { s.push("<tr><td nowrap><font size=2.5> " + attribs.Full_Address + "</font></td><td nowrap><font size=2.5>" + attribs.GIS_Key + "</font></td><td nowrap><font size=2.5>" + attribs.PIN + "</font></td><td nowrap><font size=2.5>" + attribs.Owner_Name + "</font></td><td nowrap><font size=2.5>" + attribs.Owner_Address + "</font></td><td nowrap><font size=2.5>" + attribs.Owner_City + "</font></td><td nowrap><font size=2.5>" + attribs.Owner_State + "</font></td><td nowrap><font size=2.5>" + attribs.Owner_ZIP + "</font></td><td nowrap><font size=2.5>" + attribs.Owner_Date + "</font></td><td nowrap><font size=2.5>" + attribs.Owner_Update + "</font></td><td nowrap><font size=2.5>" + attribs.Occupant_Name + "</font></td><td nowrap><font size=2.5>" + attribs.Occ_Phone1 + "</font></td><td nowrap><font size=2.5>" + attribs.Occ_Phone2 + "</font></td><td nowrap><font size=2.5>" + attribs.Village + "</font></td><td nowrap><font size=2.5>" + attribs.Active + "</font></td></tr>"); } }
//inside of a switch statement looking at the layer name returned case 'Subdivision': tcell.innerHTML = "<span style='font-weight:bold'>Subdivision History (Name and Number, sorted most recent to oldest):</span>"; tcell.innerHTML += "<br> <span style='font-style:italic'>For reference only - not to be relied upon as a legal search of the property.</span><br>"; //need to loop thru all of the idResults that are sub history //date, name, docname, annsubid var featcount = 0; while (idResults.layerName == 'Subdivision') { featval = idResults.feature.attributes['SUBDATE']; sortlist[featcount] = new Array(2); sortlist[featcount][0] = new Date(featval).valueOf(); //get date in ms for sorting sortlist[featcount][1] = "<a href='http://myserver/" + idResults.feature.attributes['LINK'] + "' target='_blank'>" + idResults.feature.attributes['NAME'] + " (" + idResults.feature.attributes['ID'] + ")</a><br>"; featcount += 1; } //sort descending sortlist.sort(numbersort); for (var z = 0, iz = featcount; z < iz; z++) { tcell.innerHTML += sortlist[1]; } break; //after the switch statement...add the cell to a table row and add that to the table above an existing row trow.appendChild(tcell); dojo.byId('tblbody').insertBefore(trow,dojo.byId('rowSummary')); // here's the basic function I used to sort numbers. note it's taking in arrays function numbersort(a, b) { //sort the 1st element in 2 arrays descending //used to sort subs, agreements, PUD docs, etc... return b[0] - a[0]; }
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.