add extra param using remoteSaveAdaptor

How can I add an extra param when using remoteSaveAdaptor? Because if I add [FromBody]Test dm on my Index Controller Method there is no answer from the server.

View:

<ej-grid id="FlatGrid" allow-paging="true" action-begin="begin">
<e-datamanager json="ViewBag.datasource" insert-url="/Usuaris/Insert" update-url="/Usuaris/Update" remove-url="/Usuaris/Remove" adaptor="remoteSaveAdaptor"></e-datamanager> <e-toolbar-settings show-toolbar="true" toolbar-items=@(new List<string>() {"add","edit","delete","update","cancel" })></e-toolbar-settings> <e-edit-settings allow-adding="true" allow-editing="true" allow-deleting="true" show-delete-confirm-dialog="true" edit-mode="Dialog" /> <e-columns> <e-column field="Id" is-primary-key="true" header-text="Id" width="70" default-value="0" visible="false"></e-column> <e-column field="UserName" header-text="UserName" text-align="Right" width="70"></e-column> </e-columns> </ej-grid>

<script type="text/javascript">
    function begin(args) {      
          args.model.query.addParams("ID", 10248)
     }
</script>

Controller:

public IActionResult Index([FromBody]Test dm)
        {
               .....
         }

        public class Test : DataManager       //inherit the class to show age as property of DataManager
        {
            public int ID { get; set; }       
        } 


1 Reply

VA Venkatesh Ayothi Raman Syncfusion Team January 2, 2018 03:54 PM UTC

Hi Jordi, 

Thanks for using Syncfusion products. 

We went through your code example that you have shared for us and found that you want to pass the additional parameter along with DataManager parameters. But you are using remoteSaveAdaptor in your Application. This adaptor works like local data source and perform the CRUD operation in server side. Please refer to the following Help documentation, 

As from your code example, we suggest you to use UrlAdaptor to bound the Grid data. If we using URL adaptor then Post request will send to server side along with DataManager Parameters. Please refer to the following Screenshot and Help documentation, 
 


In that Url adaptor we can get the additional parameter in DataManager parameters by inherits the DataManager class like your code example. Please refer to the following code example, 
<script type="text/javascript"> 
 
    function begin(args) { 
        args.model.query.addParams("ID", 10248) 
    } 
 
</script> 

Also, we can add the Add the additional parameter using query property in Grid while initial rendering. Please refer to the following code example, 
<ej-grid id="FlatGrid" datasource="@ViewBag.data" allow-paging="true"  query="new ej.Query().addParams('ID', 7)" > 
      
    
     
    <e-columns> 
        .  . . 
        
    </e-columns> 
</ej-grid> 

Otherwise, we can pass the additional parameter through AJAX function. Please let us know if you have any further assistance on this. 

Also, you can perform the Grid actions such as Paging, Filtering and Sorting in server side as well as we have already created a knowledge base documentation for this, 

Please let us know if you have any further assistance on this. 

Regards, 
Venkatesh Ayothiraman. 


Loader.
Up arrow icon