Problem refreshing ej-grid .NET core 2.0 MVC

1. I have a grid and can delete, or update with no issues

2. When i add an item it adds the item but I cannot refresh the Grid once the Entity framework code adds the item to the data context, (its just stuck with the waiting icon)
 I have looked in the forums and code and noticed others have had similar issues which your team has fixed

3. I tried to upload the project structure but the file size is just a little to large for stated max upload size (is there another way to get the code as is to your team to check for me as a corporate customer)...

4. I hope  your team can help resolve the issue as it is  a bit of a sticking point for me in development.

5. the code for the Grid is below as well as the code behind snippet.

6. NOTE I use drop downs in the grid not sure if this may be causing the none refreshing issue or what is the best way.


Thanks for your help in Advance:






Ej-Grid Control
-------------------------------------------------------------------------------------------------

 <!-- WORK WITH POST BACK!!-->
    <ej-grid runat="Server" id="GridNewProjectTeam" action-complete="onActionComplete" allow-paging="true" allow-filtering="false" SelectionType="Single">
        <e-datamanager json="(IEnumerable<object>)ViewBag.ProjectTeamDatasource" insert-url="/RicsNewPIDProjectWizard/ProjectTeamInsert" remove-url="/RicsNewPIDProjectWizard/ProjectTeamDelete" update-url="/RicsNewPIDProjectWizard/ProjectTeamUpdate" adaptor="remoteSaveAdaptor" />
        <e-edit-settings allow-adding="true" allow-editing="true" allow-deleting="true" allow-edit-on-dbl-click="true" show-delete-confirm-dialog="true" edit-mode="InlineForm"></e-edit-settings>
        <e-toolbar-settings show-toolbar="true" toolbar-items='@new List<string> {"add","edit","delete","update","cancel"}' />
        <e-columns>
            <e-column field="ID" header-text="ID" is-primary-key="true" is-identity="true" allow-editing="false"></e-column>

            <e-column field="FKMemberID" header-text="Name" is-primary-key="false" datasource="(IEnumerable<object>)ViewBag.dropDataRicsMemebers" edit-type="DropdownEdit"></e-column>
            <e-column field="FkRoleId" header-text="Role" is-primary-key="false" datasource="(IEnumerable<object>)ViewBag.dropDataRoles" edit-type="DropdownEdit"></e-column>

            <e-column field="Designation" header-text="Designation" is-primary-key="false"></e-column>
            <e-column field="ImageUrl" header-text="Image Url" is-primary-key="false"></e-column>

            <e-column field="ReportingPerson" header-text="Reporting Person" is-primary-key="false"></e-column>
            <e-column field="ReportingManager" header-text="Reporting Manager" is-primary-key="false"></e-column>

            <e-column field="CreationDate" header-text="Creation Date" is-primary-key="false" allow-editing="false" edit-type="DateTimePicker"></e-column>
            <e-column field="LastUpdated" header-text="Last Updated" is-primary-key="false" allow-editing="false" edit-type="DateTimePicker"></e-column>

        </e-columns>
    </ej-grid>




COde Behind (this seem to be stuck and not refreshing the grid!!!!)
-------------------------------------------------------------------------------------


        /// <summary>
        /// ProjectTeamInsert - Working
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public ActionResult ProjectTeamInsert([FromBody]CRUDModel<RicsProjectTeam> value)
        {

            //  Debugger.Break();

            //database contex
            RicsPIDContext RicsPidContext = new RicsPIDContext();

            if (value != null)
            {
                // return RedirectToPage("/RicsNewUser/RicsNewUserFeatures");

                //Generate ID as we are using GUIDS
                value.Value.ID = Guid.NewGuid();

                //Get ProjectID FK
                 string injectID = HttpContext.Session.GetString("CreatePIDwizardGUID");   // ViewBag("CreatePIDwizardGUID").ToString();

                //do we have a project selected ...
                if (String.IsNullOrEmpty(injectID))
                {

                    //internal error manager
                    HttpContext.Session.SetString("ExceptionNewPidVisibility", "true");
                    HttpContext.Session.SetString("ErrormessageNewPid","Please specify Project invalid project PID found are you creating a new project?");


                return Json(value);
                }

                //SAVE -   Set project ref ...
                value.Value.FkProjectId = new Guid(injectID);

                //dates
                value.Value.CreationDate = DateTime.Now;
                value.Value.LastUpdated = DateTime.Now;

                //Add the new value'
                RicsPidContext.RicsProjectTeams.Add(value.Value);

                //Apply chnages
                RicsPidContext.SaveChanges();

            }


        // this should reload the view and reset the grid I assume ...
            return  RedirectToPage("/RicsNewPIDProjectWizardFeatures", "RicsNewPIDProjectWizard");


        }




1 Reply

SE Sathyanarayanamoorthy Eswararao Syncfusion Team April 4, 2018 12:50 PM UTC

Hi Lakes, 

Thanks for contacting Syncfusion support. 

We have analyzed your query and in the given code example we found that you have used RedirectToPage() method instead of returning the JSON value. Hence we suggest you to return the JSON value after saving the changes in the db context. The inserted record will be displayed in the grid automatically. We have prepared a sample with the same requirement which can be downloaded from the below location. 


Refer the below code example. 


[index.cshtml] 
 
<ej-grid id="Grid"   action-complete="onActionComplete" allow-paging="true" allow-filtering="false" SelectionType="Single"> 
    <e-datamanager json="(IEnumerable<object>)ViewBag.dataSource" insert-url="/Home/NormalInsert" remove-url="/Home/Remove" update-url="/Home/NormalUpdate" adaptor="remoteSaveAdaptor" /> 
 
              ……..     
 
   <e-columns> 
        <e-column field="OrderID" header-text="OrderID" is-primary-key="true" is-identity="true" text-align="Right" width="30"></e-column> 
        <e-column field="CustomerID" header-text="CustomerID" edit-type="DropdownEdit" datasource="ViewBag.dataSource2" width="80"></e-column> 
        <e-column field="EmployeeID" header-text="EmployeeID" edit-type="DropdownEdit" datasource="ViewBag.dataSource1" width="80"></e-column> 
         
                          ….. 
 
   </e-columns> 
</ej-grid> 
 
 
[HomeController.cs] 
 
  public ActionResult NormalInsert([FromBody]CRUDModel<Orders> param) 
        {           
                _context.Add(param.Value); 
                _context.SaveChangesAsync(); 
            return Json(param.Value); 
 
            } 
 

Please refer the below documentation for the details of how to return the data from server side for CRUD operations. 


If you still face the issue please share the following details. 

  1. Screenshot or Video demo of the issue.
  2. Share the Insert method post details in the network tab.
  3. Share why do you need to refresh the grid after inserting a record.
  4. If possible please try to reproduce the mentioned issue in the attached sample.

Regards, 
Sathyanarayanamoorthy 



Loader.
Up arrow icon