Batch mode and save with a button outside grid

Hi,

I'm trying to do the same thing i saw in this forum, but i'm with ASP.NET Core and something does not work and i don't know why.

Here is my grid :
<ej-grid id="FlatGridEchantillonAnalyses" locale=@GetMsg("MESID_LOCALIZATION") allow-grouping="false" enable-persistence="true" enable-touch="true" show-column-chooser="true" databound="databound" action-complete="actioncomplete" allow-reordering="true" allow-resize-to-fit="true" allow-resizing="true" allow-paging="false" action-failure="OnActionFailure" allow-filtering="false" allow-sorting="false" load="onLoad">
    <e-edit-settings allow-editing="true" edit-mode="Batch" show-confirm-dialog="false"></e-edit-settings>
    <e-toolbar-settings show-toolbar="false" />
    <e-datamanager json="ViewBag.datasource" batch-url="/Logged/EchantillonAnalysesListCellEditUpdate" adaptor="remoteSaveAdaptor" />
    <e-columns>
        <e-column field="iECH_ANA_ID" header-text=@GetMsg("LIBID_ECHANT_ID") is-primary-key="true" text-align="Right" width="5" allow-editing="false"></e-column>
        <e-column field="strANA_LibelleParam" header-text=@GetMsg("LIBID_ANALYSE_LIBELLEPARAM") width="40" allow-editing="false"></e-column>
        <e-column field="strANA_LibelleMethode" header-text=@GetMsg("LIBID_ANALYSE_LIBELLEMETHODE") width="40" allow-editing="false"></e-column>
        <e-column field="strANA_Unite" header-text=@GetMsg("LIBID_ANALYSE_UNITE") width="15" allow-editing="false"></e-column>
        <e-column field="bANA_Cofrac" header-text=@GetMsg("LIBID_ANALYSE_COFRAC") text-align="Center" width="12" allow-editing="false" validation-rules='new Dictionary<string, object>() { { "customRegex", "" } }'></e-column>
        <e-column field="strECH_ANA_Resultat" header-text=@GetMsg("LIBID_ANALYSE_RESULTAT") width="40"></e-column>
        <e-column field="strECH_ANA_Interpretation" header-text=@GetMsg("LIBID_ANALYSE_INTERPRETATION") width="40" allow-editing="false"></e-column>
    </e-columns>
</ej-grid>


Here is my button :
<button id="btn" onclick="javascript:Save();">Click to save changes</button>

And here is my function :
    function Save() {
        //this.batchSave();
        var grid = $("#FlatGridEchantillonAnalyses").ejGrid("instance");
       grid.batchSave();
    }

When i click on the button, my batch-url save function (EchantillonAnalysesListCellEditUpdate) is not called. (the breakpoint in VS debugger don't stop.
Can you fix my code and/or do you have an ASP.NET Core example please ?
Thx by advance.
Fred.




10 Replies

VN Vignesh Natarajan Syncfusion Team April 24, 2018 05:47 AM UTC

Hi Frédéric, 
 
Thanks for using Syncfusion products. 
 
As per your request we have prepared a sample using your code snippets and we are able to hit the controller and save the changes. We are not able to reproduce the reported issue.  
 
Kindly download the sample from below link 
 
 
Refer the below screenshot for the output 
 
 
 
 
Share the following details to reproduce the reported issue at our end. 
 
1.       Share the full Grid rendering code 
2.       Share the screenshot of the script error in console window (if any) 
3.       Share the screenshot of the network tab in developer tools on the button is clicked with response tab. 
4.       if possible try to reproduce the reported issue or provide issue reproducible sample. 
 
Note: Ensure to run the sample in incognito mode or by clearing the caches. 
 
Regards, 
Vignesh Natarajan  



FP Frédéric Peyronnin April 24, 2018 07:32 AM UTC

Hi Vignesh and thx for your sample.
I found the problem !! it is just like the bug i found with your combobox component (issue 136550). It's working with Chrome, Firefox, but it's not working with Edge :

It says :INCORRECT REQUEST. The server could not process the request because the syntax is not valid.
Regards,
Fred.


FP Frédéric Peyronnin April 24, 2018 07:36 AM UTC

I don't know why, i can't paste a screenshot in the message.
Here it is in attached file.

Attachment: 20180424_09h21_50_808322c9.rar


VN Vignesh Natarajan Syncfusion Team April 25, 2018 01:54 PM UTC

Hi Frédéric,
We have analyzed your query issue (“Http 400 issue”). we have prepared a sample using your code snippets and we are not able to reproduce the reported issue at our end.
We have ensued the sample in Microsoft Edge browser. Record gets saved correctly.
Kindly download the sample from below link
Share the following details to reproduce the reported issue.
1. Are you using combobox control in the sample? if yes, how you are rending it into the grid.
2. Share the full grid rendering code.
3. Share the screenshot of the script error in console with full stack trace.
4. If possible try to reproduce the reported issue in provided sample or try to provide issue reproducible sample.
Regards,
Vignesh Natarajan


FP Frédéric Peyronnin April 25, 2018 02:47 PM UTC

Hi Vignesh,

I'm not using combobox in my grid and it will be difficult to isolate a sample of my code since it is encapsulated with WCF calls. I'll try to make a sample if we can't resolve the problem.

I have a problem with Edge, it is very weird.
I tried your sample with all browsers and it works good. But when i try with Edge, see the result in the screenshot in attched file.

All rows and cells are empty !
I'm using Microsoft Edge 41.16299.371.0
EdgeHTML 16.16299
On Windows 10 and Visual Studio 2017 v15.7.0 preview 4.0.
Can you understand what is happening ?


Attachment: 20180425_16h38_58_dee69c20.rar


VN Vignesh Natarajan Syncfusion Team April 26, 2018 11:12 AM UTC

Hi Frédéric,  
 
 
Thanks for the update. 
 
 
We have analyzed your issue (cell are empty and blank rows) and we suspect that reported issue occur due to camelCase issue which occur in ASP.NET core. When Camel case issue occurs, column names will be changed to small letters.  
For example. If the column name is CustomerID, while returning for the server the name will be changed as customerId. So the issue occur.  
 
To overcome from this issue we suggest you to follow the below code in the your startup.cs project  
  
public void ConfigureServices(IServiceCollection services)  
        {  
            // Add framework services.  
            ...  
  
            services.AddMvc()  
            .AddJsonOptions(x =>  
            {  
                x.SerializerSettings.ContractResolver = null;  
            });  
                   ...  
        }  
  
  
  
   
  
Else refer to the following document to solve casing problem and also mention field values in camelcase.      
 
 
 
Regards, 
Vignesh Natarajan 



FP Frédéric Peyronnin December 19, 2018 12:27 PM UTC

Hi,

Since latest versions of your ASP.NET Core JS 1 (16.3.0.29 i there is a problem with "batchSave" of the grid.

As you can see in your sample : 

myObject is null and raise an exception.
You can reproduce easily the error since it is your sample you made for me few month ago. And the link of your sample is still in this post.

Can you fix this bug please ?
Thx by advance.
FreD.



VN Vignesh Natarajan Syncfusion Team December 20, 2018 06:38 AM UTC

Hi Frédéric, 
 
Query: “Since latest versions of your ASP.NET Core JS 1 (16.3.0.29 i there is a problem with "batchSave" of the grid.” 
 
From you query and screenshot, we understood that value for myObject is returning as null. As per your suggestion we have upgraded the sample provided (on April 25th 2018) to 16.3.0.29 version. We are not able to reproduce the reported issue at our end.  
 
For your convenience we have attached the upgraded sample  
 
 
If you still face the issue, please get back to us issue reproducible sample. 
 
Regards, 
Vignesh Natarajan 
 



FP Frédéric Peyronnin December 20, 2018 10:59 AM UTC

Hi and thank's for your answer.

It's very difficult for me to isolate and make a sample with my problem since it is a part of a big project.

I have not tested this functionnality since a long time, so i don't know when it did not work anymore.

The code is quite simple :

<ej-grid id="FlatGridEchantillonAnalyses" locale=@GetMsg("MESID_LOCALIZATION") allow-grouping="false" enable-persistence="false" enable-touch="true" show-column-chooser="false" databound="databound" action-complete="actioncomplete" allow-reordering="true" allow-resize-to-fit="true" allow-resizing="true" allow-paging="false" allow-filtering="false" allow-sorting="false" load="onLoad">
    <e-page-settings [email protected](HttpContextAccessor.HttpContext.Session.GetString("strPrefNbRowsPerPage")) page-size-list="new List<int> { 10,20,30,40,50,90 }"></e-page-settings>
    <e-edit-settings [email protected](HttpContextAccessor.HttpContext.Session.GetString("strUserIsAutoControle")) edit-mode="Batch" show-confirm-dialog="true"></e-edit-settings>
    <e-datamanager json="ViewBag.datasource" batch-url="/Logged/EchantillonAnalysesListCellEditUpdate" adaptor="remoteSaveAdaptor" />
    <e-columns>
        <e-column field="iECH_ANA_ID" header-text=@GetMsg("LIBID_ECHANT_ID") show-in-column-chooser="false" is-primary-key="true" text-align="Right" width="0" allow-editing="false"></e-column>
        <e-column field="iECH_ANA_ECH_ID" header-text=@GetMsg("LIBID_ECHANT_ID") show-in-column-chooser="false" text-align="Right" width="0" allow-editing="false"></e-column>
        <e-column field="strANA_LibelleParam" header-text=@GetMsg("LIBID_ANALYSE_LIBELLEPARAM") width="40" allow-editing="false"></e-column>
        <e-column field="strANA_LibelleMethode" header-text=@GetMsg("LIBID_ANALYSE_LIBELLEMETHODE") width="40" allow-editing="false"></e-column>
        <e-column field="strANA_Unite" header-text=@GetMsg("LIBID_ANALYSE_UNITE") width="15" allow-editing="false"></e-column>
        <e-column field="strANA_Valeurs_Limites" header-text=@GetMsg("LIBID_ANALYSE_VALEURSLIMITES") width="25" allow-editing="false" format="{0:n0}"></e-column>
        <e-column field="bANA_Cofrac" header-text=@GetMsg("LIBID_ANALYSE_COFRAC") text-align="Center" width="12" allow-editing="false" validation-rules='new Dictionary<string, object>() { { "customRegex", "" } }'></e-column>
        <e-column field="strECH_ANA_Resultat" header-text=@GetMsg("LIBID_ANALYSE_RESULTAT") width="25" format="{0:n0}" allow-editing=@((string)ViewData["Sous_Traitant"] == Constantes.strAutoControle)></e-column>
        <e-column field="strECH_ANA_Interpretation" header-text=@GetMsg("LIBID_ANALYSE_INTERPRETATION") width="30" allow-editing="false"></e-column>
        <e-column field="strEtat" header-text="" show-in-column-chooser="false" width="11" template="<img style='width: 30px; height: 30px' src='/images/Rond{{:strEtat}}.png'>" allow-filtering="false" allow-editing="false" allow-resizing="false"></e-column>
    </e-columns>
</ej-grid>
        <input type="button" id="Save" onClick="return Save();" value='@GetMsg("BTNID_ANALYSESSAVE")' class="btn btn-success" />
<script type="text/javascript">
    function Save() {
        var grid = $("#FlatGridEchantillonAnalyses").ejGrid("instance");
        grid.batchSave();
    }


And in my controler :



As you see, i Always get a null value.

Can you please give me some clues i can check. Can you tell me in what case the value is passed null to the controler ?






VN Vignesh Natarajan Syncfusion Team December 21, 2018 06:59 AM UTC

Hi Frédéric, 
 
Thanks for the update. 

For your convenience we have created the sample with the updated code example, we are unable to reproduce the reported issue at our end. Please refer the below link, 


The reported issue(BatchURL method return the value as null) will occur in the below scenario, 

  1. If we use difference datasource model, then the reported issue will occur (i.e.) for grid databinding if you use the dataSource model as “OrderDetails”(for example) then you must use the same dataSource model in the BatchURL method also. Kindly, ensure whether are you using the same model. If not, please use the same model to avoid the reported issue.

Still facing the issue, please get back to us with the following details. 

  1. Please Share the complete grid view and controller page code example.
  2. Please Share the network tab post details.

The provided details will help us to resolve the reported issue as early as possible. 

Regards, 
Vignesh Natarajan. 


Loader.
Up arrow icon