i have a program and i was thinking to create an object then a function inside it. is it possible? it's like this var x = function() {....}
and i wanted to re use the variable x..
here's the code:
$("#tbl").jqGrid({
url: '',
datatype: 'local',
jsonReader : {
root: function(obj) {
//some codes here
return root;
},
page: "page",
total: "pageCount",
records: "rows",
repeatitems:false,
id: "0"
},
serializeGridData: function(postData) {
var jsonParams = {
.
.//some codes here
.
'sort_fields': postData.sidx
};
if (postData.sord == 'desc')
{
..//some codes
}
else
{
...//some codes
}
jpar = jsonParams;
return 'json=' + jsonParams;
},
loadError: function(xhr, msg, e) {
showMessage('msg error');
},
colNames:['ID',...'Type'],
colModel:[
...//col model
],
rowNum:5,
.
.
.//some codes here
loadonce:false,
caption: "Main Account Group"
});
i want to get the jsonReader, serializedGridData, and the loadError and create an object function for them. my goal here is to create an object from the functions from the above code. does anybody here knows how to do it?
by the way, what's the difference between methods and functions.? can event can be code as function? thank you all.
datatype: 'local'
in the case NO requests to the server will be done. So theserializeGridData
method will never called. How you fill the data in the grid? You definedjsonReader
. So you probably insert the data manually withaddJSONData
it is not a good way in the most cases. Could you insert more full JavaScript code, so that one could understand more your code? – Oleg Mar 22 '11 at 10:23