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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Customize grid setting value

Thread ID:

Created:

Updated:

Platform:

Replies:

141846 Jan 8,2019 01:11 AM UTC Jan 9,2019 03:54 AM UTC ASP.NET Core - EJ 2 3
loading
Tags: DataGrid
haryzad
Asked On January 8, 2019 01:11 AM UTC

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

Thavasianand Sankaranarayanan [Syncfusion]
Replied On 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 
[Index.cshtml] 
 
<div> 
    <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-columns> 
            <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> 
        </e-grid-columns> 
    </ejs-grid> 
</div> 
<script> 
   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, 

Regards, 
Thavasianand S. 


haryzad
Replied On 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;



Thavasianand Sankaranarayanan [Syncfusion]
Replied On January 9, 2019 03:54 AM UTC

Hi Haryzad, 

Thanks for your update. 

We will wait to hear from you. 

Regards, 
Thavasianand S. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon