Customization of Attribute Table

5092
34
Jump to solution
02-17-2018 10:03 AM
ZdeněkSoldán
Occasional Contributor

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

34 Replies
ShailendraVerma1
New Contributor II

It's worked well!

I have another question, can we update cell value also. Please suggest.

0 Kudos
ForrestBlack
New Contributor III

Could the code be modified to read the field alias name instead of the field name? How would this be accomplished?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Forest,

  The AT widget already shows the field alias as the column name by default...

0 Kudos
ForrestBlack
New Contributor III

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');

 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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).

ForrestBlack
New Contributor III

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');
          }‍‍‍
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Sorry, I was talking about something different then.

 In your case you just need this:

if(object['SDE.GIS.AREAS.DEVELOPER']==='Forrest'){
ForrestBlack
New Contributor III

That makes sense to use the string as an index. However, it still doesn't seem to be working.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

I think it might be without the quotes.

0 Kudos
ForrestBlack
New Contributor III

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!

0 Kudos