PDA

View Full Version : How to create different grid views for different user roles?



ppatel2
3 Jun 2013, 10:08 AM
Hello,

I am trying to create a grid for different user roles. My application creates dynamic grid based on the user roles. How can I achieve this functionality with ExtJS. All the columns will be displayed for administrator, some of the columns will be removed for the end user and so on.

Any help will be appreciated.

Thanks,
Parth

glopes
3 Jun 2013, 7:32 PM
Build your variable dynamically, placing your columns inside of it
(I haven't checked the code, but it would look like something like this)..

Columns variable code:



var dynColumns = [];
if (role == "admin") {
for (i = 0; i <= columnList.lenght; i++) {
dynColumns.push({
xtype : columnList[i].type,
dataIndex : columnList[i].dataIndex,
text : columnList[i].text
});
}
}


Grid code




xtype : 'gridpanel',
title : 'Your Title Here',
store : 'yourStoreHere',
columns : dynColumns