Forum



00:25

23/11/2011

Hello all,
I am having a problem with trying to customize jqgrid. Basically I once my data is populated from the database I need modify a piece of that data in a new field.
Here is my code:
...
jQuery("#entryGrid").jqGrid({
datatype: "local",
height: 290,
rowNum: 100,
rownumbers: true,
hidegrid: false,
cellEdit: true,
cellsubmit: "clientArray",
loadui: "block",
colNames:['', '', '', '', 'Field Name', 'Current Data', 'Select', 'Correct Data', 'Issue', 'Status'],
colModel:[
{name:'refId', index:'refId', hidden:true},
{name:'failureExplanation', index:'failureExplanation', hidden:true},
{name:'system', index:'system', hidden:true},
{name:'regex', index:'regex', hidden:true},
{name:'name', index:'name', width:155, sortable:false, editable:false},
{name:'value', index:'value', width:155, sortable:false, editable:false},
{name:'selectOption', index:'selectOption', width:90, sortable:false, editable:true, edittype:'select', formatter: 'select', editoptions:{value:"1:SSN;2:EIN"}},
{name:'correctData', index:'correctData', width:155, sortable:false, editable:true, edittype:'text', editoptions: {dataEvents:handleKeyPressEvents, size:"26", maxlength:"20"}, editrules: {custom:true, custom_func:fieldCheck} },
{name:'reason', index:'reason', width:100, sortable:false, editable:false},
{name:'status', index:'status', width:185, sortable:false, editable:false}
],
...
In a nut shell, what I am trying to do is the following....
The Col "Current Data" is the data from the database.
The Col "Select" is a feature that I added from examples from other jqgrid sources. it a select option that has the values "SSN" or "EIN"
The Col "Correct Data" is where the user will input the correct data.
I want the user to NOT have to worry about formatting the SSN or EIN (ie. ###-##-#### or ##-#######). The user can input "123456789" (ill deal with validation later) and jqgrid will change the "Correct Data" field to ###-##-#### or ##-####### depending on the Select option.
I have tried using the "custom" option and other items. Nothing seems to work.
Any guidence is appreciated.
Thank you.
07:54

Moderators
30/10/2007

Hello,
IMHO the custom func is not appropriate choice.
My first thing is that you can use some masked input plugin to format the field depending on the choice of selectOption. -
that is - you should bind a onchange event to this field and call the maksed input field plugin with different parameters to format the field.
You can use dataInit event to bind onchange event.
Regards
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
08:49

23/11/2011

Thank you for your response.
That is precisely what I have been trying to do. I have downloaded the mask plugin from :http://digitalbush.com/project.....ut-plugin/
What I can't do is bind it in jqgrid.....that is my problem....and where I need help.
08:57

Moderators
30/10/2007

Suppose you use form editing ( the difference from inline edit is the name of the id of the input field)
{
name:'selectOption',
index:'selectOption',
width:90,
sortable:false,
editable:true,
edittype:'select',
formatter: 'select',
editoptions:{
value:"1:SSN;2:EIN",
dataInit : function(elem) {
$(elem).change(function() {
//destroy the previous masked bind with command which should be available in this plugin
if( $(this).val() == '1' ) {
$('#correctData').maskedplugin({params1})
} else {
$('#correctData').maskedplugin({params2 })
}
});
}
}
}
,
Hope this helps
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
21:22

21/12/2011

Yes it is exactly what tony said to do but you have to get the id of each cell in the column you are trying to manipulate. and from my knowledge jqGrid ids are dynamically created for each row of data. If your column name is correctData then it would be something close to correctData_1, correctData_2, etc.
Most Users Ever Online: 715
Currently Online:
96 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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66