-
5 Oct 2011 8:32 AM #1
Unanswered: How to Change action column icon dynamically?
Unanswered: How to Change action column icon dynamically?
Hello,
I am trying to displayicon config dynamically base on lets say role of login person.xtype:'actioncolumn'
code is as below
I also have fields like belowCode:{ xtype:'actioncolumn', width:50, id:'actionCol', items: [{ icon: '../imgs/edit.gif', // Use a URL in the icon config tooltip: 'Edit', handler: function(grid, rowIndex, colIndex) { } }] }
site_access will have view or edit value. So, I am trying to display icon base on view or edit value.Code:var fields = [ {name: 'site_external_id', type: 'string'}, {name: 'site_name', type: 'string'}, {name: 'site_address', type: 'string'}, {name: 'site_new', type: 'string'}, {name: 'site_status', type: 'string'}, {name: 'site_access', type: 'string'}, {name: 'site_id', type: 'string'} ];
-AnkitLast edited by Ankit.Desai; 5 Oct 2011 at 8:33 AM. Reason: typo
-
6 Oct 2011 10:12 AM #2
-
6 Oct 2011 3:01 PM #3
-
11 Oct 2011 12:07 AM #4
-
11 Oct 2011 12:28 AM #5
I guess I have to post an example:
Code:{ header: 'Actions', xtype: 'actioncolumn', width: 55, fixed: true, align: 'center', getClass: this.getActionClass }Code:getActionClass: function (val, meta, rec) { if (rec.get('In') === null) { this.tooltip = 'Sign In'; return 'in'; } else if (rec.get('Out') === null) { this.tooltip = 'Sign Out'; return 'out'; } else { this.tooltip = ''; return 'none'; } }HTML Code:.x-action-col-cell img { width: 32px; height: 32px; margin-top: 3px; margin-right: 3px; cursor: pointer; background-repeat: no-repeat; background-position: center; } .x-action-col-cell img.in { background-image: url(../images/action-in-32.png); } .x-action-col-cell img.out { background-image: url(../images/action-out-32.png); }
-
11 Oct 2011 12:37 AM #6
Is there a better solution ? I will get the data from the store.
-
11 Oct 2011 12:53 AM #7
Do you mean you get the image from a store?
-
11 Oct 2011 12:56 AM #8
Sorry,
I get the published data from the store
Published 1 = green icon
Published 0 = red icon
-
11 Oct 2011 1:10 AM #9
Then do something like this:
Code:getActionClass: function (val, meta, rec) { return rec.get('published') === 1 ? "green" : "red"; }Code:{ width: 32px; height: 32px; margin-top: 3px; margin-right: 3px; cursor: pointer; background-repeat: no-repeat; background-position: center; } .x-action-col-cell img.green { background-image: url(../images/green.png); } .x-action-col-cell img.red { background-image: url(../images/red.png); }


Reply With Quote