We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Customize grid setting value

Dear Syncfusion team,

Appreciate if you can advice, how i can customize the grid setting as bellows code;
the objective currently; for the value setting how i can replace it with the viewbag so the value true / false especially on the e-grid-editseeting can be pass from controller based on the certain condition on the user roles that has been set on my application.

Thanks for the cooperation

3 Replies

TS Thavasianand Sankaranarayanan Syncfusion Team January 8, 2019 01:26 PM UTC

Hi Haryzad, 

Greetings from Syncfusion. 

We have validated your query and we have prepared a simple sample with your concern in ASP .Net Core in EJ2 Grid. We have achieved the “ViewBage.userRole” controller value basis to enable the editing support by using ‘load event. We hope that below code example is helpful for your application. Please refer the following code example, screenshot and sample for more information. 

Code example 
    <ejs-grid id="Grid" load="onLoad" allowExcelExport="true" toolbarClick="onToolBarClick">         
        <e-data-manager url="@Url.Action("UrlDatasource","Home",new { userRole = @ViewBag.userRole})" insertUrl="@Url.Action("Insert","Home")" updateUrl="@Url.Action("Update","Home")" removeUrl="@Url.Action("Remove","Home")" adaptor="UrlAdaptor" ></e-data-manager> 
            <e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" validationRules="@(new { required=true})" textAlign="Right" width="120"></e-grid-column> 
            <e-grid-column field="CustomerID" headerText="Customer Name" validationRules="@(new { required=true})" width="150"></e-grid-column> 
            <e-grid-column field="Freight" headerText="Freight" format="C2" width="120"></e-grid-column> 
            <e-grid-column field="ShipCity" headerText="Ship City" minWidth="20" maxWidth="500"></e-grid-column> 
            <e-grid-column field="ShipCountry" headerText="Ship Country" width="150"></e-grid-column> 
   function onLoad(args) {  
        var gridObj = document.getElementById('Grid').ej2_instances[0]; 
        var userRole = "@ViewBag.userRole"; 
        if (userRole === "admin") { 
           this.editSettings = { allowAdding: true, allowEditing: true, allowDeleting: true, mode: "Dialog", showDeleteConfirmDialog: true }; 
            this.toolbar = ["Add", "Edit", "Update", "Delete","Cancel", "ExcelExport"];             

In following Screenshot shown the output of additional parameter value in server side which is passed from the data manager 

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

Thavasianand S. 

HA haryzad January 8, 2019 02:34 PM UTC

Dear Thavasianand S. 

Thanks for the fast respond, already run through the sample given; got some idea to implement it;

will try on my application code and let you know if there are any issues.

thanks for the cooperation;

TS Thavasianand Sankaranarayanan Syncfusion Team January 9, 2019 03:54 AM UTC

Hi Haryzad, 

Thanks for your update. 

We will wait to hear from you. 

Thavasianand S. 

Live Chat Icon For mobile
Up arrow icon