private void SetUpGrid(DataGrid grid, string nameColumnDataField, string idColumnDataField) { grid.Columns.Clear(); var nameColumn = new BoundColumn { HeaderText = " ", DataField = nameColumnDataField }; nameColumn.ItemStyle.Width = Unit.Parse("150px"); nameColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Right; grid.Columns.Add(nameColumn); var idColumn = new BoundColumn { HeaderText = "", DataField = idColumnDataField, Visible = false }; grid.Columns.Add(idColumn); foreach (PermissionInfo permission in _permissions) { var templateCol = new TemplateColumn(); var columnTemplate = new PermissionTriStateTemplate(permission) { IsFullControl = IsFullControl(permission), IsView = IsViewPermisison(permission), SupportDenyMode = SupportsDenyPermissions(permission) }; templateCol.ItemTemplate = columnTemplate; var locName = ""; if (permission.ModuleDefID > 0) { if (!String.IsNullOrEmpty(ResourceFile)) { //custom permission locName = Localization.GetString(permission.PermissionName + ".Permission", ResourceFile); } } else { //system permission locName = Localization.GetString(permission.PermissionName + ".Permission", PermissionProvider.Instance().LocalResourceFile); } templateCol.HeaderText = !String.IsNullOrEmpty(locName) ? locName : permission.PermissionName; templateCol.HeaderStyle.HorizontalAlign = HorizontalAlign.Center; templateCol.HeaderStyle.VerticalAlign = VerticalAlign.Bottom; templateCol.ItemStyle.HorizontalAlign = HorizontalAlign.Center; templateCol.ItemStyle.Width = Unit.Parse("70px"); templateCol.HeaderStyle.Wrap = true; grid.Columns.Add(templateCol); } }
private void SetUpGrid(DataGrid grid, string nameColumnDataField, string idColumnDataField, string permissionHeaderText) { grid.Columns.Clear(); var nameColumn = new BoundColumn { HeaderText = permissionHeaderText, DataField = nameColumnDataField }; nameColumn.ItemStyle.CssClass = "permissionHeader"; nameColumn.HeaderStyle.CssClass = "permissionHeader"; grid.Columns.Add(nameColumn); var idColumn = new BoundColumn { HeaderText = "", DataField = idColumnDataField, Visible = false }; grid.Columns.Add(idColumn); foreach (PermissionInfo permission in _permissions) { var templateCol = new TemplateColumn(); var columnTemplate = new PermissionTriStateTemplate(permission) { IsFullControl = IsFullControl(permission), IsView = IsViewPermisison(permission), SupportDenyMode = SupportsDenyPermissions(permission) }; templateCol.ItemTemplate = columnTemplate; var locName = (permission.ModuleDefID <= 0) ? Localization.GetString(permission.PermissionName + ".Permission", PermissionProvider.Instance().LocalResourceFile) //system permission : (!String.IsNullOrEmpty(ResourceFile) ? Localization.GetString(permission.PermissionName + ".Permission", ResourceFile) //custom permission : ""); templateCol.HeaderText = !String.IsNullOrEmpty(locName) ? locName : permission.PermissionName; templateCol.HeaderStyle.Wrap = true; grid.Columns.Add(templateCol); } var actionsColumn = new ImageCommandColumn { CommandName = "Delete/" + nameColumnDataField, KeyField = idColumnDataField, IconKey = "Delete", IconSize = "16x16", IconStyle = "PermissionGrid", HeaderText = Localization.GetString("PermissionActionsHeader.Text", PermissionProvider.Instance().LocalResourceFile) }; grid.Columns.Add(actionsColumn); grid.ItemCommand += grid_ItemCommand; }
private void SetUpUsersGrid() { if (userPermissionsGrid != null) { userPermissionsGrid.Columns.Clear(); var textCol = new BoundColumn(); textCol.HeaderText = " "; textCol.DataField = "DisplayName"; textCol.ItemStyle.Width = Unit.Parse("150px"); textCol.ItemStyle.HorizontalAlign = HorizontalAlign.Right; userPermissionsGrid.Columns.Add(textCol); var idCol = new BoundColumn(); idCol.HeaderText = ""; idCol.DataField = "userid"; idCol.Visible = false; userPermissionsGrid.Columns.Add(idCol); TemplateColumn templateCol; foreach (PermissionInfo objPermission in _permissions) { templateCol = new TemplateColumn(); var columnTemplate = new PermissionTriStateTemplate(); columnTemplate.DataField = objPermission.PermissionName; columnTemplate.EnabledField = objPermission.PermissionName + "_Enabled"; columnTemplate.SupportDenyMode = SupportsDenyPermissions(objPermission); templateCol.ItemTemplate = columnTemplate; string locName = ""; if (objPermission.ModuleDefID > 0) { if (!String.IsNullOrEmpty(ResourceFile)) { //custom permission locName = Localization.GetString(objPermission.PermissionName + ".Permission", ResourceFile); } } else { //system permission locName = Localization.GetString(objPermission.PermissionName + ".Permission", PermissionProvider.Instance().LocalResourceFile); } templateCol.HeaderText = !String.IsNullOrEmpty(locName) ? locName : objPermission.PermissionName; templateCol.HeaderStyle.VerticalAlign = VerticalAlign.Bottom; templateCol.ItemStyle.HorizontalAlign = HorizontalAlign.Center; templateCol.ItemStyle.Width = Unit.Parse("70px"); templateCol.HeaderStyle.Wrap = true; userPermissionsGrid.Columns.Add(templateCol); } } }