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

Changing grid editSettings in code

Thread ID:

Created:

Updated:

Platform:

Replies:

143283 Mar 12,2019 09:16 PM UTC Mar 13,2019 05:26 AM UTC ASP.NET Core - EJ 2 1
loading
Tags: DataGrid
Michael Lambert
Asked On March 12, 2019 09:16 PM UTC

I'm trying to change the editSettings and toobar of a ejs-grid in script and it's not working..

        <ejs-grid id="grdTS" load="grdTS_Load" toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" })" allowPaging="true"
                  actionBegin="actionBegin">
            <e-data-manager url="/Officers/TimeSheet?handler=DataSource" updateUrl="/Officers/TimeSheet?handler=UpdateData"
                            insertUrl="/Officers/TimeSheet?handler=InsertData" adaptor="UrlAdaptor"></e-data-manager>
            <e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true"></e-grid-editSettings>
            <e-grid-columns>

I'm just testing with a change event for a dropdown.  The code does run but nothing happens.  You can still edit the grid and the menu stays the same.

    function monthChange(args) {
        var gridObj = document.getElementById("grdTS").ej2_instances[0]
        gridObj.editSettings.allowEditing = "false"
        gridObj.toobar = "@(new List<string>() { "Add", "Cancel" })"
    }


Pavithra Subramaniyam [Syncfusion]
Replied On March 13, 2019 05:26 AM UTC

Hi Michael, 
 
Greetings from Syncfusion. 
 
You can achieve your requirement by setting the Boolean value to the editSettings.allowEditing property in JavaScript and assigning an array of string value for grid.toolbar property. Please refer to the below code example and documentation link for more information. 
 
[index.cshtml] 
<ejs-button id="disable" content="Disable"></ejs-button> 
 
<ejs-grid id="grdTS" dataSource="ViewBag.data" toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" })" allowPaging="true" 
          > 
    <e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true"></e-grid-editSettings> 
    <e-grid-columns> 
        <e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" textAlign="Right" width="120"></e-grid-column> 
        .  .  . 
    </e-grid-columns> 
</ejs-grid> 
 
<script> 
    document.getElementById('disable').addEventListener('click', function(args) { 
        var gridObj = document.getElementById("grdTS").ej2_instances[0] 
        gridObj.editSettings.allowEditing = false; 
        gridObj.toolbar = ["Add", "Cancel"]; 
    }); 
</script> 
 
 
 
                              https://ej2.syncfusion.com/javascript/documentation/api/grid/#toolbar  
 
Please contact us if you need any further assistance on this. 
 
Regards, 
Pavithra 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