Display matrix of check boxes inside a Grid

Hello there!,

We have implemented following functionality using the Grid. As you can see, each site can have different permissions. User can grant permissions by checking one or more check boxes, and saving them as a bulk. For generating header, we are using different collection.



Following is the structure of data bound to check boxes with two-way bindings. Kindly note that I have stripped off unwanted properties and entries. Number of check boxes per row can grow up-to 19. 'checkPermission' property is used to manage the checked state.

[
{
        "siteID": 1,
        "siteName": "Test Site 1",
        "permissionItems": [{
                "permission": {
                    "permissionID": 18,
                    "name": "RuleCreateEdit",
                    "displayName": "Rule Create/Edit",
                    "displayOrderID": 6,
                    "isDisabled": null,
                    "applicationModuleID": 1
                },
                "checkPermission": false
            }, {
                "permission": {
                    "permissionID": 4,
                    "name": "FileUpload",
                    "displayName": "File Upload",
                    "displayOrderID": 8,
                    "isDisabled": null,
                    "applicationModuleID": 1
                },
                "checkPermission": false
            }
        ]
    }
]

Below view code is used to render checkboxes and other functionalities in the grid.

<ejs-grid #sitePermissionsGrid id='sitePermissionsGrid' allowTextWrap='true' [rowHeight]='25' [allowPaging]='true' [pageSettings]="permissionGridPageOptions" 
    [allowSorting]="true" [allowFiltering]='true' [filterSettings]='filterOptions' (dataBound)='sitePermissionsGridDataBound()'
    [frozenColumns]='1' allowResizing='true' [contextMenuItems]="siteAccessGridContextMenuItems" (contextMenuClick)='sitePermissionGridContextMenuClick($event, data)' 
    (contextMenuOpen)='sitePermissionsGridcontextMenuOpen($event)' allowScrolling='true' [allowExcelExport]='true' 
    [selectionSettings]='permissionGridSelectionOptions' height="100%" (rowDataBound)='rowDataBound($event)'>
    <e-columns>
        <e-column headerTextAlign='center' field='siteName' [customAttributes]='permissionsCustomAttributes' 
            headerText='Accessibile Sites ' textAlign='left ' width=200 [allowFiltering]='true '>
        </e-column>
        <e-column headerTextAlign='center' textAlign='left' [customAttributes]='permissionsCustomAttributes' [(width)]="permissionColumnWidth" 
            [allowFiltering]=' false ' [allowSorting]='false '>
            <ng-template #template let-data>
                <div *ngFor="let userAccessPermissionInformationItem of data.permissionItems | callback: filterPermission">
                    <div style="text-align: center; float: left;width: 90px;height: auto;margin-right: 5px;">
                        <input type="hidden" [(ngModel)]="data.isDirty">
                        <ejs-checkbox [(checked)]="userAccessPermissionInformationItem.checkPermission" [disabled]="!data.isDirectUserAccess" 
                        (change)='onPermissionCheckBoxChange(userAccessPermissionInformationItem, data) '>
                        </ejs-checkbox>
                    </div>
                </div>
            </ng-template>
            <ng-template #headerTemplate>
                <div *ngFor="let permission of permissions">
                    <div style="text-align: center; float: left;width: 90px;height: auto;margin-right: 5px;">
                        <span>{{permission.displayName}}</span>
                    </div>
                </div>
            </ng-template>
        </e-column>
    </e-columns>
</ejs-grid>

Even though above method works and render checkboxes properly binding to the data, if we move scroll bar horizontally up to the last checkbox column and click on it, scroll bar will reset back to default location. Item will be checked/uncheck but user has to use the scroll bar to again move to last checked location. Is there a better way to implement this check box matrix on the Grid. This had been implemented using Silverlight and client need the exact behavior on Angular app. Appreciate your suggestions and support.

Thank you!

Yasas 



3 Replies

DR Dhivya Rajendran Syncfusion Team February 19, 2020 06:39 PM UTC

Hi Yasas, 

Greetings from Syncfusion support. 
 
Query : if we move scroll bar horizontally up to the last checkbox column and click on it, scroll bar will reset back to default location. 
 
We have validated the provided information and we were unable to reproduce the reported problem at our end. We have created a simple sample with checkboxes in the column template, please refer the below sample. 


Please share the below or more details that will help us to validate and provide an better solution as soon as possible. 

  1. Share the packages version of syncfusion controls.
  2. Try to reproduce the reported problem in the given sample and share with us.
  3. Did you performed any action while when changing the checkboxes at last column.
  4. Share the full grid code html page and ts page.
  5. Share any video demonstration of the reported problem.

Regards, 
R.Dhivya         



YP Yasas Petangoda February 21, 2020 05:03 AM UTC

Hi Dhivya,

Thanks a lot for the quick reply. Unfortunately the example you have provided is not loading for us( https://angular-udaqpk-tqalbo.stackblitz.io/)
We are using grid package version 17.3.27. I have attached source code and a screen recording of how scroll bar jumps back.

Best Regards,

Yasas


Attachment: Files_26575432.zip


DR Dhivya Rajendran Syncfusion Team February 24, 2020 01:10 PM UTC

Hi Yasas, 

Sorry for the inconvenience caused. 

We have created a new sample with the provided code example but still we cannot able to reproduce it. Please refer the below sample for more information. 


We need some clarification about your query. Please share the more or below details that will help us to validate and provide an better solution as soon as possible 

  1. In your grid, you have doing some customization(action) in the checkbox change event. Please explain the details about what action have be done in the checkbox change event?
  2. Did you changed grid datasource in checkbox change event?
  3. Did you perform dynamic filtering or any other grid actions while click the checkbox.
  4. If possible share the sample or replicate the reported problem with our sample

Regards, 
R.Dhivya 


Loader.
Up arrow icon