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

How to specify parameters to an OData query that expects parameters?

How do I specify parameters on an OData query method? I now understand how to specify a filter, but cannot figure out how to specify parameters? I cannot find this in the online help at all...

Here is a valid odata query with two parameters (serviceId and view) that I am trying to replicate:


I've tried something like the following but it doesn't work:

grid_actionBegin = function (args) {
        var serviceId = 3;
        var view = "Default";
        args.model.query = ej.Query()
            .addParams("serviceId", serviceId)
            .addParams("view", view);

5 Replies

MS Madhu Sudhanan P Syncfusion Team March 7, 2014 07:08 AM UTC

Hi Xander,


The addParams function is designed to accept parameter values as string and function and hence it is not considering the integer type parameters.


We have confirmed that the issue with “Adding integer type custom parameter” is a defect and we have logged a defect report. The fix for this issue will be included in our Volume 1, 2014 release on the month of April.


For now we can add the integer type parameter to the url by passing function as the parameter. The parameter function will  return the integer value. Please refer the following code snippet.



grid_actionBegin = function (args) {

            args.model.query = ej.Query()

                .addParams("serviceId", serviceId)

                .addParams("view", view);



function serviceId() { return 3; }


function view() { return "Default"; }



For your convenience, we have created a simple sample please find the sample from the attachment.


Please let us know if you have any queries.



Madhu Sudhanan. P

Attachment: F115967_916f7920.zip

XV Xander van der Merwe March 10, 2014 03:26 AM UTC

Thanks, using functions work, but when the function returns a string you have to return that string enclosed in single quotes or it will not work. For example:

function view() { return "Default"; }    // does NOT work

function view() { return "'Default'"; }  // does work

I'm not sure whether this is a SyncFusion issue/requirement or a Lighswitch OData issue/requirement.


MS Madhu Sudhanan P Syncfusion Team March 10, 2014 09:30 AM UTC

Hi Xander,


The addParams will provide parameters that can be added to the query. While generating query, the parameter types are not considered so single quotes are not added to the string type parameters.


If we want to pass the string type parameter through the URL, we have to wrap the parameter with the single quotes as follow.



function action(args) {

            args.model.query = ej.Query().addParams("view", param2);       



function param2() { return "'Default'"; }


And hence it will be added in the url as follow.






Please let us know if you have any queries.



Madhu Sudhanan. P

XV Xander van der Merwe March 10, 2014 09:35 AM UTC

OK thanks, so it is by design. 

Might be a good idea to add something about that into your documentation as it took me a little while to work out why the query was giving an "invalid syntax error..." - specifically for Lightswitch developers.

Thank you.

MS Madhu Sudhanan P Syncfusion Team March 11, 2014 12:37 PM UTC

Hi Xander,


Ok, thanks for your update.


Please get to us back if you require further assistance, we will be glad to help you out.



Madhu Sudhanan. P

Live Chat Icon For mobile
Up arrow icon