Hello,
is it possible to customize the Attribute Table in Web AppBuilder App based on attribute of features? What I need is change color of the row if some attribute has error state.
Thanks a lot
Regards
Zdenek
Solved! Go to Solution.
It's worked well!
I have another question, can we update cell value also. Please suggest.
Could the code be modified to read the field alias name instead of the field name? How would this be accomplished?
Forest,
The AT widget already shows the field alias as the column name by default...
Thanks for the quick reply. I was referring to how the code you provided references the actual layer field name, not the alias.
My issue is that because I have a joined table, the original attribute table name is automatically added to the field name. For example, the field name of my layer is "SDE.GIS.AREAS.DEVELOPER" instead of "DEVELOPER".
If I plug the entire name with the dots. Nothing is highlighted. I tested and it works on unjoined field names (ex. just "Developer").
aspect.around(this.grid, "renderRow", function(original) {
return function(object) {
var row = original.apply(this, arguments);
if(object.SDE.GIS.AREAS.DEVELOPER==='Forrest'){ //object is the row data object so change the field name to your own
html.addClass(row, 'goldRow');
}
if(object.SDE.GIS.AREAS.STATUS=== 'Primary'){ //object is the row data object so change the field name to your own
html.addClass(row, 'darkgreenRow')
}
if(object.SDE.GIS.AREAS.STATUS=== 'Alternate'){ //object is the row data object so change the field name to your own
html.addClass(row, 'lightgreenRow')
}
}
return row;
};
});
this.emit('data-loaded');
OK, I have never tried with a joined layer. You can use field# where number is the zero index placement of that field (i.e. field3 would be the fourth column).
That is an excellent suggestion! This is for the third field.
Would the correct syntax be as below? It doesn't seem to be working...
if(object.field2==='Forrest'){
html.addClass(row, 'goldRow');
}
I also tried
if(object.field[2]==='Forrest'){
html.addClass(row, 'goldRow');
}
Sorry, I was talking about something different then.
In your case you just need this:
if(object['SDE.GIS.AREAS.DEVELOPER']==='Forrest'){
That makes sense to use the string as an index. However, it still doesn't seem to be working.
I think it might be without the quotes.
I don't think I should remove the quotes. When I do it breaks the AT widget and causes the table to not populate.
Going back to your earlier comment, what syntax would you suggest I use to implement referencing the numbered index of the field? That might be easier.
Thank you so much for your help. Programming with the Web AppBuilder has been quite a learning curve!