This is a migrated thread and some comments may be shown as answers.

Dollar signs being removed from query string parameters

1 Answer 396 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Toby
Top achievements
Rank 1
Toby asked on 13 Jun 2012, 09:38 AM
Hi,

Does anyone know if there is an obvious configuration entry that would do this, before I start delving into it more.

Currently my URL to the ODATA service is using the following

/_vti_bin/listdata.svc/Inventory?take=5&skip=0

It needs to have the dollar signs before each of the parameters for it to work.

Any ideas?

Cheers

My custom odata file

/*
* Kendo UI Web v2012.1.322 (http://kendoui.com)
* Copyright 2012 Telerik AD. All rights reserved.
*
* Kendo UI Web commercial licenses may be obtained at http://kendoui.com/web-license
* If you do not own a commercial license, this file shall be governed by the
* GNU General Public License (GPL) version 3.
* For GPL requirements, please review: http://www.gnu.org/copyleft/gpl.html
*/
(function($, undefined) {
    var kendo = window.kendo,
        extend = $.extend,
        odataFilters = {
            eq: "eq",
            neq: "ne",
            gt: "gt",
            gte: "ge",
            lt: "lt",
            lte: "le",
            contains : "substringof",
            endswith: "endswith",
            startswith: "startswith"
        },
        mappers = {
            pageSize: $.noop,
            page: $.noop,
            filter: function(params, filter) {
                if (filter) {
                    params.$filter = toOdataFilter(filter);
                }
            },
            sort: function(params, orderby) {
                params.$orderby = $.map(orderby, function(value) {
                    var order = value.field.replace(/\./g, "/");


                    if (value.dir === "desc") {
                        order += " desc";
                    }


                    return order;
                }).join(",");
            },
            skip: function(params, skip) {
                if (skip) {
                    params.$skip = skip;
                }
            },
            take: function(params, take) {
                if (take) {
                    params.$top = take;
                }
            }
        },
        defaultDataType = {
            read: {
                dataType: "jsonp"
            }
        };


    function toOdataFilter(filter) {
        var result = [],
            logic = filter.logic || "and",
            idx,
            length,
            field,
            type,
            format,
            operator,
            value,
            filters = filter.filters;


        for (idx = 0, length = filters.length; idx < length; idx++) {
            filter = filters[idx];
            field = filter.field;
            value = filter.value;
            operator = filter.operator;


            if (filter.filters) {
                filter = toOdataFilter(filter);
            } else {
                field = field.replace(/\./g, "/"),


                filter = odataFilters[operator];


                if (filter && value !== undefined) {
                    type = $.type(value);
                    if (type === "string") {
                        format = "'{1}'";
                        value = value.replace(/'/g, "''");
                    } else if (type === "date") {
                        format = "datetime'{1:yyyy-MM-ddTHH:mm:ss}'";
                    } else {
                        format = "{1}";
                    }


                    if (filter.length > 3) {
                        if (filter !== "substringof") {
                            format = "{0}({2}," + format + ")";
                        } else {
                            format = "{0}(" + format + ",{2})";
                        }
                    } else {
                        format = "{2} {0} " + format;
                    }


                    filter = kendo.format(format, filter, value, field);
                }
            }


            result.push(filter);
        }


        filter = result.join(" " + logic + " ");


        if (result.length > 1) {
            filter = "(" + filter + ")";
        }


        return filter;
    }


    extend(true, kendo.data, {
        schemas: {
            odata: {
              type: "json",
              data: "d.results",
              total: "d.__count"
          }        
        },
        transports: {
          odata: {
              read: {
                  cache: true, // to prevent jQuery from adding cache buster
                  dataType: "jsonp",
               //   jsonp: "$callback"
              },
              parameterMap: function(options, type) {
                  type = type || "read";
 
                  var params = {
                          $inlinecount: "allpages"
                      },
                      option,
                      dataType = (this.options || defaultDataType)[type].dataType;
 
                  options = options || {};
 
                  for (option in options) {
                      if (mappers[option]) {
                          mappers[option](params, options[option]);
                      } else {
                          params[option] = options[option];
                      }
                  }
                  return params;
              }
          }
      }        
      }
    });
})(jQuery);

My datasource parameters

var dataSource = new kendo.data.DataSource({
type: "odata.sharepoint",
transport: {
read:
{
url: "_vti_bin/listdata.svc/Inventory",
contentType: "application/json; charset=utf-8" ,
type: "GET",
dataType: "json"
}
},
schema: {
data: "d.results",
total: "d.__count",
model: {
fields: {
Make: { type: "string" },
Model: { type: "string" },
Price: { type: "number" },
PictureUrl: { type: "string" }
}
}
},
pageSize: 5,
serverPaging: true,
serverFiltering: true,
serverSorting: true
});



1 Answer, 1 is accepted

Sort by
0
Jeff
Top achievements
Rank 1
answered on 12 Oct 2012, 07:21 PM
For me, It seems to includ ethe dollar signs as long as I include the type: "odata" property:

new kendo.data.DataSource({
            type: "odata",
Tags
Data Source
Asked by
Toby
Top achievements
Rank 1
Answers by
Jeff
Top achievements
Rank 1
Share this question
or