1

Hello Every One!!! I added codes for getting unique dropdownlist in the columns of jqgrid . Dropdownlist is coming but it is coming for the first page of the jqgrid means that dropdownlist has the unique values of the first page of the jqgrid whereas i need all the unique values of the whole Jqgrid..

Below I am posting my codes...

grid = $("#gridId");

        getUniqueNames = function (columnName) {
            var texts = grid.jqGrid('getCol', columnName), uniqueTexts = [],
            textsLength = texts.length, text, textsMap = {}, i;
            for (i = 0; i < textsLength; i++) {
                text = texts[i];
                if (text !== undefined && textsMap[text] === undefined) {
                    // to test whether the texts is unique we place it in the map.
                    textsMap[text] = true;
                    uniqueTexts.push(text);
                }
            }
            return uniqueTexts;
        },
        buildSearchSelect = function (uniqueNames) {
            var values = ":All";
            $.each(uniqueNames, function () {
                values += ";" + this + ":" + this;
            });
            return values;
        },
        setSearchSelect = function (columnName) {
            grid.jqGrid('setColProp', columnName,
            {
                stype: 'select',
                searchoptions: {
                    value: buildSearchSelect(getUniqueNames(columnName)),
                    sopt: ['eq']
                }
            }
        );
        };

This function i have called like this...

setSearchSelect('extension');
                grid.jqGrid('setColProp', 'Name',
                    {
                        searchoptions: {
                            sopt: ['cn'],
                            dataInit: function (elem) {
                                $(elem).autocomplete({
                                    source: getUniqueNames('Name'),
                                    delay: 0,
                                    minLength: 0
                                });
                            }
                        }
                    });


                setSearchSelect('username');
                grid.jqGrid('setColProp', 'Name',
                    {
                        searchoptions: {
                            sopt: ['cn'],
                            dataInit: function (elem) {
                                $(elem).autocomplete({
                                    source: getUniqueNames('Name'),
                                    delay: 0,
                                    minLength: 0
                                });
                            }
                        }
                    });

In between these two code snippets I am loading data into jqgrid locally using Ajax call. Any help will be heartely appreciated.. Thanx in advance..

4

1 回答 1

0

我相信 getCol 只会从 jqgrid 返回当前加载的数据(对于定义的列)。因为起初您只加载第一页,所以自动完成无法知道列的唯一值更多!

您将不得不一次加载所有页面(小数据集)或从数据库填充自动完成。

于 2013-04-03T05:02:32.267 回答