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

Binding combobox to odata service and case insensitive.

1 Answer 302 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Satish
Top achievements
Rank 1
Satish asked on 18 Apr 2012, 11:12 PM
I want to bind a combobox to a remote odata service to do a case insensitive search of the dataTextField. Setting ingoreCase property doesn't seem to do anything. So I'm trying to set up a custom query string like this  /Countries?$filter=startswith(tolower(Name),tolower('Ca')) 
explained in this stackoverflow post using parameterMap function but cant seem to get my function right. What should be the correct parameterMap function.
.kendoComboBox({
                                        dataTextField: "Description",
                                        dataValueField: "Code",
                                        minLength: 3,
                                        autoBind: false,
                                        dataSource: {
                                            type: "odata",
                                            serverPaging: true,
                                            pageSize: 30,
                                            transport: {
                                                read: {
                                                    url: odataUrl,
                                                    dataType: "json"
                                                },
                                                parameterMap: function (options) {
                                                    if (options.filter) {
                                                        var thisfilter = filter.filters[0];
                                                        return { filter: thisfilter.operator + "(tolower('" + thisfilter.value + "'), tolower(" + thisfilter.field };
 
                                                    }
                                                }
 
 
                                            }
                                        }
                                    });
What should the parameterMap function return?

1 Answer, 1 is accepted

Sort by
0
Satish
Top achievements
Rank 1
answered on 19 Apr 2012, 08:19 PM
I was able to make some progress now my code looks like this 
$("#combobox").kendoComboBox({
    dataTextField: "Description",
    dataValueField: "Code",
    minLength: 3,
    autoBind: false,
    filter: "contains",
    ignoreCase: true,
    dataSource: {
        type: "odata",
        serverfiltering: false,
        serverPaging: true,
        pageSize: 30,
        transport: {
            read: {
                url: odataUrl,
                dataType: "json"
            },
            parameterMap: function (options, type) {
                if (options.filter) {
                    options.filter.filters[0].value = "tolower(" + options.filter.filters[0].value + ")";
                    options.filter.filters[0].field = "tolower(" + options.filter.filters[0].field + ")";
                }
                return kendo.data.transports["odata"].parameterMap(options, type);
            }
        }
    }
});
So now the request url looks like this <odataURL>?%24format=json&%24inlinecount=allpages&%24top=30&%24filter=substringof('tolower(2us)'%2Ctolower(Description)). Now the problem is the entire value section is enclosed in quotes 'tolower(2us)' instead of tolower('2us'). Is there some way to fix that?

Tags
ComboBox
Asked by
Satish
Top achievements
Rank 1
Answers by
Satish
Top achievements
Rank 1
Share this question
or