Dispaly record in gridview on first position after save fails .
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)
SIGN IN To post a reply.
5 Replies
AS
Alan Sangeeth S
Syncfusion Team
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.
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.
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
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
BB
Bharat Buddhadev
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
}
RU
Ragavee U S
Syncfusion Team
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.
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?
Attachment: stacktrace_79cfa3d8.7z
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
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
BB
Bharat Buddhadev
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
RU
Ragavee U S
Syncfusion Team
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
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
SIGN IN To post a reply.
- 5 Replies
- 3 Participants
-
BB Bharat Buddhadev
- Aug 20, 2015 11:11 AM UTC
- Sep 4, 2015 07:33 AM UTC
8/26/2026 10:04:22 PM
Sun, 15 December 2024 03:30:00 UTC
Sun, 15 December 2024 03:30:00 AM
Wed, 16 Feb 2022 04:59:00 UTC