Dynamic Row Editing

Hi,

Is there a way to dynamically decide which rows can be edited when double clicked? My model has a boolean for each dataset that has the correct editing permissions, so I thought I would just use it in the allowEditing variable of individual columns:
<e-grid-column field="GridId" headerText="GridId" allowEditing="false" isPrimaryKey="true" visible="false" showInColumnChooser="false"></e-grid-column>
                        <e-grid-column field="ObjectiveId" headerText="ObjectiveId" allowEditing="false" defaultValue="@Model.Objective.ObjectiveId" visible="false" showInColumnChooser="false"></e-grid-column>
                        <e-grid-column field="FiscalYear.Description" headerText="FY" allowEditing="CanEdit" editType="dropdownedit" defaultValue="@currentFiscalYear" edit="new {@params = fiscalYearDropDownList }"></e-grid-column>
                        <e-grid-column field="ReportingPeriod.Description" headerText="Quarter" editType="dropdownedit" defaultValue="@currentReportingPeriod" edit="new {@params = reportingPeriodDropDownList }"></e-grid-column>

But it doesn't know what that is. I guess only the field variable can read the model...?


4 Replies 1 reply marked as answer

SM Shalini Maragathavel Syncfusion Team October 9, 2020 12:37 PM UTC


Hi Jessica, 

Greetings from Syncfusion Support. 

Based on your query we suspect that you want to edit the row dynamically in the Grid. You can achieve your requirement by using actionBegin event of the Grid as demonstrated in the below code snippet, 

<ejs-grid id="Grid" dataSource="ViewBag.dataSource"  actionBegin="actionBegin" toolbar="@(new List<string>(){"Add","Update","Delete","Cancel"})"  allowPaging="true" height="300"> 
    <e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true"></e-grid-editSettings> 
    <e-grid-columns> 
        <e-grid-column field="OrderID" width="110" isPrimaryKey=true></e-grid-column> 
        <e-grid-column field="CustomerID" headerText="CustomerID" width="110"></e-grid-column> 
        <e-grid-column field="Freight" headerText="Freight" format="#,##0.00€" textAlign="Right"  width="120"></e-grid-column> 
        <e-grid-column field="Verified" headerText="Verified" width="110"></e-grid-column> 
        
    </e-grid-columns> 
 
</ejs-grid> 
<script> 
    
    function actionBegin(args) { 
         
        if (args.requestType === 'beginEdit' && args.rowData.Verified==false) { 
             
            args.cancel = true; 
        }  
 
    } 
 
    
</script> 

Please find the 
below sample for more information. 

Please get back to us if you need further assistance. 

Regards, 
Shalini M. 




Marked as answer

JG Jessica Goodrich October 9, 2020 09:59 PM UTC

Hi Shalini,

I was unable to get this to work based on the code snippet and when I try to download the sample code it takes me to a "Bad Request - Invalid URL" page.


JG Jessica Goodrich October 9, 2020 10:39 PM UTC

Ok, I restarted and gave it another try and now it is working. Thanks!


MS Manivel Sellamuthu Syncfusion Team October 12, 2020 05:26 AM UTC

Hi Jessica, 

We are glad that your requirement has been resolved. 

Please get back to us, if you need further assistance. 

Regards, 
Manivel 


Loader.
Up arrow icon