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

Grid not updated after New Recorded is added

Thread ID:

Created:

Updated:

Platform:

Replies:

128652 Feb 2,2017 04:17 PM Feb 9,2017 11:01 AM ASP.NET MVC 3
loading
Tags: Grid
Michael Lambert
Asked On February 2, 2017 04:17 PM

I'm using inline editing in the Grid.  When I insert a new record and after saving it, it disappears from the Grid.  I created a button with:
            var gridObj = $("#OneCloudGrid").ejGrid("instance");
            gridObj.refreshContent();
It reappears after I press it!
Seems like the grid needs to be refreshed after an Insert to display the newly added record.  My question is, where would I place these lines of code so that I don't have to press the button after every add.  I would think actionComplete("add"), put that seems to fires right after the add new button is pressed, before the record is even saved.

Mike

Prasanna Kumar Viswanathan [Syncfusion]
Replied On February 3, 2017 07:52 AM

Hi Michael, 

Thanks for contacting Syncfusion support. 

Before we proceed with your query, please confirm the following details 

1. You have mentioned when insert a new record and after saving it, it disappears from the Grid. So, are you using any adaptors like URL, remoteSave etc.? 
 
2. Code example of a Grid and controller. 
 
3. While using adaptors and if you face any exception on grid save action, Share the screenshot of an exception.   
 
4.  Have you enable isIdentity property for the primary key column? 
 
5. If possible, share the video demonstration of an issue. 
 
6. Essential Studio Version details.  

Regards, 
Prasanna Kumar N.S.V 


Michael Lambert
Replied On February 8, 2017 01:08 PM



Here is the controller data: (Full code attached)
        public ActionResult GetData(Syncfusion.JavaScript.DataManager dm)
        {
            System.Collections.IEnumerable Data = db.Requests.ToList();
            sgDataResult result = new sgDataResult();
            Syncfusion.JavaScript.DataSources.DataOperations operation = new Syncfusion.JavaScript.DataSources.DataOperations();
            if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting
                Data = operation.PerformSorting(Data, dm.Sorted);
            if (dm.Where != null && dm.Where.Count > 0) //Filtering
                Data = operation.PerformWhereFilter(Data, dm.Where, dm.Where[0].Operator);
            if (dm.Search != null && dm.Search.Count > 0) //searching
                Data = operation.PerformSearching(Data, dm.Search);

            List<string> str = new List<string>();
            if (dm.Aggregates != null)
            {
                for (var i = 0; i < dm.Aggregates.Count; i++)
                    str.Add(dm.Aggregates[i].Field);
                result.aggregate = operation.PerformSelect(Data, str);
            }

            int count = Data.AsQueryable().Count();

            if (dm.Skip != 0)
                Data = operation.PerformSkip(Data, dm.Skip);
            if (dm.Take != 0)
                Data = operation.PerformTake(Data, dm.Take);
            result.count = count;
            result.result = Data;
            return Json(result, JsonRequestBehavior.AllowGet);
        }

        public ActionResult Insert(Request value)
        {
            value.Created = DateTime.Now;
            value.CreatedBy = ((AuthUser)Session["user"]).Name;
            value.ISChoice = "OneCloud";
            db.Requests.Add(value);   value of value.RequestID (which is the PK) = 0 - which is correct at this time
            try
            {
                db.SaveChanges();
after SaveChanges the value of value.RequestID(PK) should be updated to the new PK value but it's still 0
            }
            catch (Exception ex)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Database Error: " + ex.Data);
            }
            return Json(value, JsonRequestBehavior.AllowGet);
        }


View Data
    @(Html.EJ().Grid<Request>("OneCloudGrid")
                                .Datasource(ds => ds.URL(@Url.Action("GetData", "AdminOC")).UpdateURL(@Url.Action("Update", "AdminOC")).InsertURL(@Url.Action("Insert", "AdminOC")).Adaptor(AdaptorType.UrlAdaptor))
                                .EditSettings(edit => { edit.AllowEditing().AllowAdding(); })
                                .AllowScrolling(true)
                                .AllowPaging(true)

.
.
.
.
            .Columns(col =>
            {
                col.Field(p => p.RequestID).HeaderText("Request ID").AllowEditing(false).IsIdentity(true).IsPrimaryKey(true).TextAlign(TextAlign.Center).Width(93).Add();
                col.Field(p => p.Period).HeaderText("Period").Width(82).TextAlign(TextAlign.Center).EditType(EditingType.Dropdown).DataSource(Model.ddlists.nsPeriod).Add();





Attachment: Code_720aa7c4.zip

Thavasianand Sankaranarayanan [Syncfusion]
Replied On February 9, 2017 11:01 AM

  
Hi Michael, 

We have analyzed your query and we are unable to reproduce the reported issue in our end. If isIdentity is enabled in grid column, the newly added record will be added in the grid. 

We have attached a video link of sample execution and it will be downloadable in the below location. 
 
 
Please provide the following details, for better assistance. 
1.       Video demonstration of issue. 
2.       Clear replication  procedure of issue. 
3.       Essential studio version. 
4.       If possible, replicate the issue in the attached sample. 
 
We have prepared a sample for your convenience and it can be downloadable in the below location. 

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.

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.

;