▲
0
▼
|
1. in database create enum field (values:DEFAULT VALUE, YES, NO) for radio buttons values
2. jqgrid column type
1
2
3
4
5
6
7
8
9
10
11
12
13
| {
name: 'confrim',index:'confrim', label: 'Confirmed?',
edittype: 'custom', width: 70, align: "center", editable: true, editoptions:
{
custom_element: radioelem,
custom_value: radiovalue,
},
formatter: 'radioVisualizer',
formatoptions:
{
disabled: false
}
} |
{
name: 'confrim',index:'confrim', label: 'Confirmed?',
edittype: 'custom', width: 70, align: "center", editable: true, editoptions:
{
custom_element: radioelem,
custom_value: radiovalue,
},
formatter: 'radioVisualizer',
formatoptions:
{
disabled: false
}
}
3. prepare functions for renedering and value manipulation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
| $.extend($.fn.fmatter, {
radioVisualizer: function (cellvalue, options, rowObject) {
return cellvalue;
}
});
function radiovalue(elem, operation, value) {
var obj = $(elem);
debugger;
if (operation === 'get')
{
if(!value)
return "DEFAULT VALUE";
return obj.filter('input:checked').val();
} else if (operation === 'set') {
if(value && value != "DEFAULT VALUE"){
if (obj.is(':checked') === false) {
return obj.filter('[value=' + value + ']').attr('checked', true);
}
}else{
return "DEFAULT VALUE";
}
}
}
$.extend($.fn.fmatter.radioVisualizer, {
unformat: function (cellValue, options, elem) {
var text = $(elem).text();
return text === ' ' ? '' : text;
}
});
function radioelem(value, options) {
var receivedradio = '';
receivedradio += 'YES';
var naradio = 'NO';
if (value == 'YES') {
var radiohtml = receivedradio + ' checked="checked"' + breakline + naradio + endnaradio;
return radiohtml;
} else if (value == 'NO') {
var radiohtml = receivedradio + breakline + naradio + ' checked="checked"' + endnaradio;
return radiohtml;
} else {
return receivedradio + breakline + naradio + endnaradio;
}
} |
$.extend($.fn.fmatter, {
radioVisualizer: function (cellvalue, options, rowObject) {
return cellvalue;
}
});
function radiovalue(elem, operation, value) {
var obj = $(elem);
debugger;
if (operation === 'get')
{
if(!value)
return "DEFAULT VALUE";
return obj.filter('input:checked').val();
} else if (operation === 'set') {
if(value && value != "DEFAULT VALUE"){
if (obj.is(':checked') === false) {
return obj.filter('[value=' + value + ']').attr('checked', true);
}
}else{
return "DEFAULT VALUE";
}
}
}
$.extend($.fn.fmatter.radioVisualizer, {
unformat: function (cellValue, options, elem) {
var text = $(elem).text();
return text === ' ' ? '' : text;
}
});
function radioelem(value, options) {
var receivedradio = '';
receivedradio += 'YES';
var naradio = 'NO';
if (value == 'YES') {
var radiohtml = receivedradio + ' checked="checked"' + breakline + naradio + endnaradio;
return radiohtml;
} else if (value == 'NO') {
var radiohtml = receivedradio + breakline + naradio + ' checked="checked"' + endnaradio;
return radiohtml;
} else {
return receivedradio + breakline + naradio + endnaradio;
}
}
|