Forum

July 12th, 2025
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
filtertoolbar defaultValue
29/04/2010
21:24
Avatar
daanl
Member
Members
Forum Posts: 3
Member Since:
29/04/2010
sp_UserOfflineSmall Offline

Hello,

Im having some weird issue, i have put the this in the colmodel {name: 'test', index: 'test', search : 'true', stype: 'text', searchoptions: { defaultValue: 'asdfasf'}}


when the grid loads the data (ajax call) it doesn't uses the defaultValue and the field for the filters

var config = {
"url:"http://theurl",
"datatype":"json",
"colNames":["test"],
"colModel":[ {"name":"test","index":"test","search":true,"stype":"text","searchoptions":{"defaultValue":"asdfasdf"}} ],
"rowNum":10,
"rowList":[10,20,30],
"pager":"pager",
"sortname":"test",
"viewrecords":true,
"sortorder":"asc",
"height":"100%",
"autowidth":true,
"viewsortcols":[false,"horizontal",true],
"filterable":true,
"imgpath":"js",
"search":true,
"jsonReader":{"repeatitems":false,"id":"0"}
};

$('#testingrid').jqGrid(config);
$('#testingrid').filterToolbar({
                    autosearch: true,
                    searchOnEnter: false,
                    stringResult:true,    
                    });

The url will give this: http://theurl?something&_s.....p;sord=asc

instead of:

http://theurl?something&_s.....D%2C%7B%22

Does someone know how to use the default value in the filters when the grid loads for the first time.

Thanks!

Greets
30/04/2010
12:42
Avatar
daanl
Member
Members
Forum Posts: 3
Member Since:
29/04/2010
sp_UserOfflineSmall Offline

Found the solution, using the beforeRequest, im appending the extra criterium this way the first request takes also

the filter data:

config.beforeRequest = function()

{
    if (!$(this).getPostDataItem('filters'))
    {
        $(this).appendPostData({"filters":"{"groupOp":"AND","rules":[{"field":"test","op":"bw","data":"asdf"}"});
    }
};

Im also using an cookie to set the data when filtering and echoing the cookie (im using php)

with appendPostData(<?php echo $_COOKIE['filterthing'] ?>) so it will result to:

{"filters":"{"groupOp":"AND","rules":[{"field":"test","op":"bw","data":"asdf"}"}

$('#testinggrid').filterToolbar({
        autosearch: true,
        searchOnEnter: false,
        stringResult:true,
        beforeSearch: function()
            {
                $.cookie('filterthing', JSON.stringify($('#testinggrid').getGridParam('postData')));
            }
    });

You will need the jquery cookie plugin to use this way with the cookie or get some other javascript cookie thing

if you want to remeber the user input in the filter columns, if not the onbeforeRequest thing is the only thing you'll

need.

getGridParam will return an object so you need to set it to a string or set an object cookie.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 994

Currently Online:
10 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information