Post grid data on razor page post

Is there some example about how to post grid data back to BindProperty on razor page post?

My cs file is like this:



and the page with the grid is like this:



So, the grid renders ok, and the data is ok after opening the page.


But when I change something in the grid data



and I want to save the page data



the BindProperty PodProizvodi is empty.
Maybe some hint on how to get the grid data back to BindProperty?

Thanks!
Bernard.

3 Replies 1 reply marked as answer

RR Rajapandi Ravi Syncfusion Team September 28, 2020 11:57 AM UTC

Hi Bernard, 

Greetings from syncfusion support 

We have analyzed your query and we suspect that you like to perform the crud action at server side. So we suggest you to use the Remotesave adaptor of Grid. Datasource must be set to json property and set RemoteSaveAdaptor to the adaptor property. CRUD operations can be mapped to server-side using updateUrl, insertUrl, removeUrl, batchUrl, crudUrl properties. For your convenience we have attached the sample. Please refer the below sample and documentation for more information. 



If it does not meet your requirement, Please share us your exact requirement scenario with detailed description. 

Regards, 
Rajapandi R 



BJ Bernard Jurlina September 28, 2020 08:50 PM UTC

Hi Rajapandi!

Thanks for the answer. 
I wanted to post grid data in BindProperty after I click on Submit button of the form, so I thought there is some example for that.

Regards,
Bernard.



RR Rajapandi Ravi Syncfusion Team September 30, 2020 11:31 AM UTC

Hi Bernard, 

We have analyzed your query and we could see that you like to post the grid data to the controller on form submit. Based on your requirement we have prepared a sample and we suggest you to use the below way to achieve your requirement. Please refer the below code example , sample and screenshot for more information. 

 
    <script type="text/javascript"> //button click event 
        document.getElementById("submitBtn").addEventListener("click", function (args) { 
            debugger; 
            var grid = document.getElementsByClassName("e-grid")[0].ej2_instances[0];  
            var rowsDetails = grid.dataSource; //send the grid datasource 
            $.ajax({ 
                url: "/Home/Data", 
                type: "POST", 
                datatype: "json", 
                contentType: "application/json; charset=utf-8", 
                data: JSON.stringify({ gid: rowsDetails }), 
                success: function (result) { 
                     
                } 
            });   
        }) 
    </script> 


Screenshot: 

 


Regards,
Rajapandi R 


Marked as answer
Loader.
Up arrow icon