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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Dispaly record in gridview on first position after save fails .

Thread ID:

Created:

Updated:

Platform:

Replies:

119985 Aug 20,2015 11:11 AM UTC Sep 4,2015 07:33 AM UTC JavaScript 5
loading
Tags: ejGrid
Bharat Buddhadev
Asked On August 20, 2015 11:11 AM UTC

Waiting for your quick reply 
Its urgent 

Technology  : Must be angualr js and mvc


point 1  I do not want to allow edit functionality in Grid view
Point 2 after insert record in gridview click on save
Point 3 If I am getting error while save I want to display that newly added record again on first position of grid  and It should be display in textbox like before save. (means textbox should be open with old data)

Alan Sangeeth S [Syncfusion]
Replied On August 21, 2015 10:07 AM UTC

Hi Bharath,

Thanks for using Syncfusion products.

Query 1: “Disable Editing”

We can disable editing in Grid using “allowediting” Grid property. Please refer the following code snippets.

<div id="grid" ej-grid e-datasource="data" e-actionfailure="failure" e-editsettings-allowediting='false' e-editsettings-allowadding='true'>



Query 2: “Need to display added record in Edit Form after error on save”

We suspect that you need to validate record details in the server-side. By default, if error or exceptions occurred in server-side during save operation, then added record would not be saved in Grid and it remain still showing EditForm in Grid row.

We can validate the added record and show the error occurred in server-side using “actionfailure” Grid event. Please refer the following code snippets.

<div id="grid" ej-grid e-datasource="data" e-actionfailure="failure"  e-allowpaging="true" >


$scope.failure = function (args) {

                  this.model.isEdit = true

                  alert(args.error.statusText);

              }


public ActionResult Insert(Supplier value)

        {

            if (!ModelState.IsValid)

            {

                var message = string.Join(" | ", ModelState.Values

       .SelectMany(v => v.Errors)

       .Select(e => e.ErrorMessage));

                return new HttpStatusCodeResult(HttpStatusCode.BadRequest, message);

            }


}



For your convenience we have created a sample and the same can be downloaded from below link.

Sample:  http://www.syncfusion.com/downloads/support/forum/119985/ze/CRUDandValidation-22652058

In the above sample, if we enter invalid value for Email field it will be validated in server-side and shows error message in view.

Please let us know if you need any further assistance.

Regards,
Alan Sangeeth S

Bharat Buddhadev
Replied On August 22, 2015 09:44 AM UTC

Happy to hear from you but i have some problem with this code.

I am using webapi to insert record in database. so when i call webapi from javascript(AngularJS) i got error in catch part. see below code snippet for better understanding.

$scope.actioncomplete = function (args) {
            $scope.gridActionResult("");
            if (args.requestType === $scope.action) {
                $scope.cmisIsValid = true;
                $scope.gridActionResult(administrationResources.verifyingCmis);
               //Api call for save record                
                listCmisServices.saveUserSettings(args.data)
                    .then(function (result) {
                        $scope.cmisIsValid = true;
                        $scope.gridActionResult("");
                    })
                    .catch(function (error) {
                        $scope.gridActionResult(error);
                        $scope.cmisIsValid = false;                  
                    });
                $scope.resizeWindow();
            }
}

$scope.failure = function (args) {
            console.log(args);
            args.model.isEdit = true
        }



Ragavee U S [Syncfusion]
Replied On August 24, 2015 11:41 AM UTC

Hi Bharat,

We have analyzed the reported issue and we need few details from your end in order to assist you effectively.

1.       Could you please let us know the usage of saveUserSettings() method in your sample project?
2.       If possible, please share the code snippet corresponding to the saveUserSettings() function
3.       Could you please share the stack trace of the exception/error obtained in the catch part.

For your convenience, we have modified our sample to use Webapi service and the same can be downloaded from the below location.

Sample Link: http://www.syncfusion.com/downloads/support/forum/119985/ze/Sample-124030196

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

Regards
Ragavee U S

Bharat Buddhadev
Replied On September 3, 2015 01:12 PM UTC

Hello,

I am sharing you little bit of code as per your request.

        [SqlExceptionFilterAttribute]
        [ValidationFilterAttribute]
        [Route("api/administration/saveUserSettings/")]
        public UserSettings Post(DatabaseServer serverToAdd)
        {
            return AddDBServerSetting(serverToAdd);
        }
public UserSettings AddDBServerSetting(DatabaseServer serverToAdd)
        {
            if (serverToAdd == null)
                throw new ArgumentNullException("serverToAdd");

            _settings = RetrieveUserSettings();
            CheckDbServerForUniqueness(serverToAdd);
            DatabaseOverview databaseOverview = CheckPdbVersion(serverToAdd);
            serverToAdd.PdbName = databaseOverview.DatabaseName;
            _userSettingDataStore.SaveSettings(_settings);

            return _settings;
        }

and i also sharing you stack trace with you.

i see your attached code but i can't find any useful solution related to this issue.

Kind regards,
Bharat

Attachment: stacktrace_79cfa3d8.7z

Ragavee U S [Syncfusion]
Replied On September 4, 2015 07:33 AM UTC

Hi Bharat,

In the provided screenshot, we found that the server returned a general 403 forbidden exception. The POST request is not triggered from Grid Control and it has been triggered manually.

Please refer to the following link for handling the 403 forbidden issue,

http://forums.asp.net/t/1809768.aspx?IIS+7+0+always+returns+403+when+I+try+to+access+one+of+my+mapped+HTTP+routes

Since we are quite unclear about the requirement, please provide clear details on triggering a POST in actionComplete event of the Grid.

Regards,
Ragavee U 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.

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

;