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. Image for the cookie policy date

Attach Data Post

hi
I attach desired data in the POST data manager

exemple :
var dataMangerCategorie = ej.DataManager({
    url: "http://" + window.location.hostname + "/Layout/json.php?TYPE=AGENDACATEGORIE",
    crossDomain:true, 
Data : { :"1,2,3,4" , L: "99999xxxx, 88sssss}
});

Regards
Yvan

5 Replies

RU Ragavee U S Syncfusion Team November 26, 2015 04:57 AM UTC

Hi Yvan,

Thanks for contacting Syncfusion support.

We analyzed your requirement to pass additional parameters to the ejDataManager POST request. We suggest you to use the addParams method of ej.Query() and pass the query to executeQuery method of the ejDataManager.

The ej.Query() is used to retrieve data from the dataSource based on the query passed using the ej.Query() methods. The executeQuery method of the ejDataManager is used to execute the queries passed to it on the datamanager when remote data is bound as dataSource.

Please refer to the below online documentation for more information on the various methods available in ejDataManager and ejQuery.

https://help.syncfusion.com/api/js/ejquery#methods:addparams

https://help.syncfusion.com/api/js/ejdatamanager#methods:executequery

Regards,
Ragavee U S.


YT Yvan Theaudin November 26, 2015 07:14 PM UTC

Hi 

I just tested it sends the GET not POST
Thanks 

Attachment: img_fc87ed7e.zip


RU Ragavee U S Syncfusion Team November 27, 2015 10:22 AM UTC

Hi Yvan,

We suggest you to use UrlAdaptor inorder to send a POST request using ejDataManager. Please refer to the below online documentation for more information on Data Adaptors.

https://help.syncfusion.com/js/datamanager/data-adaptors

Please refer to the below online blog for a sample explaning CRUD operations in Grid control rendered using PHP.

https://www.syncfusion.com/blogs/post/grid-control-for-javascript-in-php.aspx

We can pass the additional parameters to the ejDataManager query as in the below code snippet.

var data = ej.DataManager({

    url: 'http://localhost/phpservice/server.php/?action=get_Data',

    insertUrl: 'http://localhost/phpservice/server.php/?action=insert_Data',

    updateUrl: 'http://localhost/phpservice/server.php/?action=update_Data',

    removeUrl: 'http://localhost/phpservice/server.php/?action=delrec',

    adaptor: new ej.UrlAdaptor()
}).executeQuery(ej.Query().addParams("EmployeeID", 1).take(50));


Regards,
Ragavee U S.


MG Marco Giorgi replied to Ragavee U S May 1, 2019 04:29 PM UTC

Hi Yvan,

We suggest you to use UrlAdaptor inorder to send a POST request using ejDataManager. Please refer to the below online documentation for more information on Data Adaptors.

http://help.syncfusion.com/js/datamanager/data-adaptors

Please refer to the below online blog for a sample explaning CRUD operations in Grid control rendered using PHP.

http://www.syncfusion.com/blogs/post/Grid-Control-for-JavaScript-in-PHP.aspx

We can pass the additional parameters to the ejDataManager query as in the below code snippet.

var data = ej.DataManager({

    url: 'http://localhost/phpservice/server.php/?action=get_Data',

    insertUrl: 'http://localhost/phpservice/server.php/?action=insert_Data',

    updateUrl: 'http://localhost/phpservice/server.php/?action=update_Data',

    removeUrl: 'http://localhost/phpservice/server.php/?action=delrec',

    adaptor: new ej.UrlAdaptor()
}).executeQuery(ej.Query().addParams("EmployeeID", 1).take(50));


Regards,
Ragavee U S.

if you add .executeQuery(ej.Query().addParams("EmployeeID", 1).take(50)) as suggested you will delete all the other parameters sent by the grid like skip and top for the paging...
So this solution is useless in a real scenario.

Could you please provide a valid solution for adding parameters, possibly as POST variables to the ej.DataManager attached to an ejGrid.

            var dataManager = ej.DataManager({
                url: "/webapi/markets",
                adaptor: new ej.WebApiAdaptor()
            });

            $("#Grid").ejGrid({
                dataSource: dataManager,
                allowPaging: true,
                columns: [
                    { field: "MarketID", headerText: "ID", isPrimaryKey: true, width: 60, textAlign: ej.TextAlign.Center },
                    { field: "MarketName", headerText: "Name", width: 200 }
                ]
            });

in example send as 'marketName' parameter a string, 'something123', taken from an input text, in order to filter the results from the API by MarketName='something'




VN Vignesh Natarajan Syncfusion Team May 2, 2019 05:46 AM UTC

Hi Marco, 
 
Thanks for contacting Syncfusion support.  
 
Query: Could you please provide a valid solution for adding parameters, possibly as POST variables to the ej.DataManager attached to an ejGrid. in example send as 'marketName' parameter a string, 'something123', taken from an input text, in order to filter the results from the API by MarketName='something'  
 
From the above query, we are able to understand that you want to pass the additional parameter to the server end and based on the passed value you need to filter the records. To achieve your requirement, we suggest you to use the below solution. We have used actionBegin event to pass the additional Parameters to server in the query string using addParams property of ejGrid..  
 
 
$("#Grid").ejGrid({ 
      dataSource: ej.DataManager({ 
          url: "/api/Orders", 
          adaptor: new ej.WebApiAdaptor() 
      }),……... 
     allowPaging: true, 
      pageSettings: { pageCount: 10, pageSize: 5 }, 
     ……………. 
      actionBegin: "actionBegin", 
     columns: [ 
          ………………. 
     ] 
 
            }); 
 
    function actionBegin(args) { 
        args.model.query.addParams("MarketName", "Chennai"); // pass the additional parameter in the actionBegin event using addParams method. 
    } 
 
 
</script> 
 
// Controller Side 
 
        [HttpGet] 
        public object Get() 
        { 
            var queryString = System.Web.HttpContext.Current.Request.QueryString; 
            var parameter = queryString["MarketName"]; 
 
            // do your stuff here. 
 
        } 
 
 
 
 
 
 
 
 
 
Output screenshot 
 
 
 
Refer our API documentation for your reference 
 
 
If you are facing any issue with above solution, please get back to us with essential studio version (xx.x.x.xx).  
 
Regards, 
Vignesh Natarajan. 
 


Loader.
Up arrow icon