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
Unfortunately, activation email could not send to your email. Please try again.
Essential JS2

Syncfusion jQuery based widgets are no longer in active development. Switch to our pure JavaScript based next generation Essential JS 2 library.

Syncfusion Feedback

how to change default value while adding

Platform: jQuery |
Control: ejGrid |
Published Date: March 1, 2017 |
Last Revised Date: March 1, 2017
Tags: grid, asp, js, mvc

While adding a new record in grid, by default in edit form it shows ‘0’ for number/integer column and “ ”(empty string) for string column. In certain cases, you may want to change that value in add edit form, this can be achieved by using defaultValue property of columns.

This property helps to define the specified default value while adding a new record in the Grid.

API Document link: https://help.syncfusion.com/api/js/ejgrid#members:columns-defaultvalue

JS

 

MVC

 

ASP

 

The following screenshot shows the specified default values while adding the record.

Figure 1: Output

ADD COMMENT
You must log in to leave a comment
Comments
JIjo
Jun 12, 2021

actionBegin: function(args) { if (args.requestType == "add") { args.data.LocationId = localStorage.getItem('location'); }

}

actionComplete: function(args) { if (args.requestType == 'save') {

            localStorage.setItem('location', args.rowData.LocationId || 0);
        }
Reply
Padmavathy Kamalanathan [Syncfusion]
Jun 14, 2021

Hi Jijo,

Greetings from Syncfusion Support.

From your update, we suspect that you are trying to set default value to one of your columns while adding new record to Grid. We can see that you are saving particular column value from rowData in actionComplete event with requestType “save” to the local storage. Then you retrieve the saved column value and set it to new record you are adding in the actionBegin event with requestType “add”.

We have created sample with your code, and it works at our end. Please check the below sample, https://jsplayground.syncfusion.com/qscvavbo

In the above sample, we have saved “EmployeeID” column value in local storage and used it to set default value to newly added records.

Still facing the issue, kindly share us the below details,

  1. Explain us your issue/requirement in detail with exact scenario
  2. Video demo of the issue
  3. Screenshot of error with complete stack trace (if any)
  4. If possible, share us issue reproducible sample or reproduce the issue in the sample shared above.

Regards, Padmavathy Kamalanathan

Please sign in to access our KB

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

Up arrow icon

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