Grid Checkbox

When i select on grid checkbox to true , i want to flip the readonly tofalse for the dropdown 
When checkbox not selected, the readonly shd be true for dropdown
isSelected is true/false

readonly="!data.isSelected"




 <e-column  textAlign='Center' width=90>
                    <ng-template #template let-data>
                        <div>
                            <ejs-checkbox id="check" name="check" [(ngModel)]="data.isSelected" label="Default">
                            </ejs-checkbox>
                        </div>
                    </ng-template>
                </e-column>
                <e-column [allowEditing]='false' field='name' headerText='Name' textAlign='Left' width=100></e-column>
                <e-column [allowEditing]='false' field='jobTitle' headerText='Title' textAlign='Center' width=100>
                </e-column>

                <e-column headerText='Permission' textAlign='Left' width=90>
                    <ng-template #template let-data>
                        <div>
                            <ejs-dropdownlist name="ddPod" id="ddPod" [(ngModel)]="data.permissionId" readonly="!data.isSelected"
                                [fields]='portfolioAccessFields' placeholder='Select Permission'
                                [dataSource]='dataPortfolioAccessTypes'>
                            </ejs-dropdownlist>
                        </div>
                    </ng-template>
                </e-column>


9 Replies 1 reply marked as answer

VI vin replied to vin January 28, 2021 01:55 AM UTC

When i select on grid checkbox to true , i want to flip the readonly tofalse for the dropdown 
When checkbox not selected, the readonly shd be true for dropdown
isSelected is true/false

readonly="!data.isSelected"




 <e-column  textAlign='Center' width=90>
                    <ng-template #template let-data>
                        <div>
                            <ejs-checkbox id="check" name="check" [(ngModel)]="data.isSelected" label="Default">
                            </ejs-checkbox>
                        </div>
                    </ng-template>
                </e-column>
                <e-column [allowEditing]='false' field='name' headerText='Name' textAlign='Left' width=100></e-column>
                <e-column [allowEditing]='false' field='jobTitle' headerText='Title' textAlign='Center' width=100>
                </e-column>

                <e-column headerText='Permission' textAlign='Left' width=90>
                    <ng-template #template let-data>
                        <div>
                            <ejs-dropdownlist name="ddPod" id="ddPod" [(ngModel)]="data.permissionId" readonly="!data.isSelected"
                                [fields]='portfolioAccessFields' placeholder='Select Permission'
                                [dataSource]='dataPortfolioAccessTypes'>
                            </ejs-dropdownlist>
                        </div>
                    </ng-template>
                </e-column>


Any help pls!!


AG Ajith Govarthan Syncfusion Team January 29, 2021 02:16 AM UTC

Hi vin, 
 
Thanks for contacting Syncfusion support. 
 
Query: When i select on grid checkbox to true , i want to flip the readonly tofalse for the dropdown When checkbox not selected, the readonly shd be true for dropdown isSelected is true/false 
 
Based on the attached code example and the query you want to make the dropdown component to be read-only when you uncheck the checkbox and similarly when you check the checkbox you want to disable the read-only property. 
 
Based on that we have prepared sample in that we have used the change event of the check box component and using the change event we have changed the read-only property based on the checkbox state. For your convenience we have attached the sample. So please refer them for your reference. 
 
Code Example: 
App.component.ts 
 
  chboxChange(args) { 
    let currentTr = parentsUntil(args.event.target, "e-row"); 
    let dropObj = currentTr.querySelector(".e-control.e-dropdownlist")[ 
      "ej2_instances" 
    ][0]; 
    dropObj.readonly = !args.checked; 
  } 
 
 
Please get back to us if you need further assistance. 
 
Regards, 
Ajith G. 


Marked as answer

VI vin January 30, 2021 08:20 PM UTC

Thanks 
I need to ensure, the dropdown is selected ONLY when the checkbox is selected

 <e-column headerText='Permission' textAlign='Left' width=90>
                    <ng-template #template let-data>
                        <div>
                            <label *ngIf="data.isSelected  &&  data.permissionId === 0 " for="ddPod" class="labels"
                            [ngClass]="{'e-error ts-bold': ( usersAdd.submitted && data.isSelected &&  data.permissionId === 0  ) }">
                            Please Select
                        </label>
                            <ejs-dropdownlist name="ddPod" id="ddPod" [(ngModel)]="data.permissionId"   [readonly]="!data.isSelected" 
                                [fields]='portfolioAccessFields' placeholder='Select Permission' required
                                [dataSource]='dataPortfolioAccessTypes' (change)="ddChanged($event, data)"   >
                            </ejs-dropdownlist>
                        </div>
                    </ng-template>
                </e-column>


AG Ajith Govarthan Syncfusion Team February 1, 2021 11:55 AM UTC

Hi vin, 
 
Thanks for the update. 
 
Query: I need to ensure, the dropdown is selected ONLY when the checkbox is selected 
 
In our previous update we have provided sample and in that sample we have showed the popup list in the dropdown only when the checkbox is in the checked state using the read-only property of the dropdown component. 
 
So, please confirm that you want to prevent the focus also in the dropdown component when the checkbox is unchecked or please explain more details on your query with screenshots to validate further on your requirement. 
 
Regards, 
Ajith G. 
 
 



VI vin February 1, 2021 08:25 PM UTC

I need to do a required validation for dropdown when the checkbox is checked 


VI vin replied to vin February 3, 2021 02:26 AM UTC

I need to do a required validation for dropdown when the checkbox is checked 

Any suggestions


MS Manivel Sellamuthu Syncfusion Team February 3, 2021 11:26 AM UTC

Hi vin, 

Thanks for your update. 

In Grid by default validation will be performed while editing only. Since we have rendered the dropdown and checkbox in the column template it is not feasible to perform validation for dropdown. 

Please let us know, if you need further assistance. 

Regards, 
Manivel 



NG Nagendra Gupta April 7, 2022 09:18 AM UTC

Hey Team,


Given Example Work Fine at Row Level but I need to checked all row checkbox after click on header leve



JC Joseph Christ Nithin Issack Syncfusion Team April 8, 2022 02:24 PM UTC

Before proceeding to the solution, please ensure your requirement is to add a check box and dropdown to the header and when you click on the header checkbox you want to change the read-only mode of the dropdown in the header? Or is your requirement is to change the read-only mode of all the dropdowns in the grids content when you check or uncheck the checkbox in the header?


Please get back to us with the details requested so that we may be able to proceed further.


Loader.
Up arrow icon