Forum
Hello
I need to build a custom search element, that contains checkboxes. When user presses Find it should send a sum of all checked checkboxes. Insted of it sends a last clicked (checked/unchecked) checkbox value.
Here is an element code:
editoptions:{
custom_element: function(value, options) {
return Parent.getActivityScopeElement(value, options);
},
custom_value: function(elem, operation, value) {
return Parent.getActivityScopeValue(elem, operation, value);
},
defaultValue: function() {
return 0;
}
},
formatter: function(cellvalue, options, rowObject) {
var scope = $j.parseJSON( Runtime.getParam('scope_activity')), ret = [], sum=0;
$j.extend(scope.buyer, scope.seller);
$j.each(scope.buyer, function(i, el) {
if(cellvalue & i) {
ret.push(el) ;
}
});
return ret.slice(', ') + '<input type="hidden" value="'+(cellvalue)+'" />';
},
unformat:function(cellvalue, options, rowObject) {
return $j(rowObject).find('input[type=hidden]').val();
},
stype: 'custom',
searchoptions: {
sopt:['cn'],
custom_element: function(value, options) {
return Parent.getActivityScopeElement(value, options);
},
custom_value: function (elem, operation, value) {
return Parent.getActivityScopeValue(elem, operation, value);
}
},
sorttype:'string',editrules:{custom:true, custom_func:Parent.checkActivityScope}, formoptions:{elmprefix: html.span("(*)", {'class':'prefix float_left'})} }
var scope = $j.parseJSON( Runtime.getParam('scope_activity') );
var elemStr = '<table class="activity_scope"><thead><tr><th>Buyer's side</th><th>Seller's side</th></tr></thead><tbody>';
elemStr += '<tr>';
elemStr += '<td>';
$j.each(scope.buyer, function(i, el) {
var checked = i & value? 'checked="checked"' : '';
elemStr += '<div><input type="checkbox" name="activity_scope" value="'+ i +'" '+checked+' /><label>'+ el +'</label></div>';
});
elemStr += '</td>';
elemStr += '<td>';
$j.each(scope.seller, function(i, el) {
var checked = i & value? 'checked="checked"' : '';
elemStr += '<div><input type="checkbox" name="activity_scope" value="'+ i +'" '+checked+' /><label>'+ el +'</label></div>';
});
elemStr += '</td>';
elemStr += '</tr>';
elemStr += '</tbody></table>';
return $j(elemStr)[0];
};
this.getActivityScopeValue = function(elem, operation, value) {
if(operation === 'get') {
var val = 0;
$j(elem).find("input:checked").each(function(i, el){
val += parseInt( $j(el).val() );
});
return val;
} else if(operation === 'set') {
$j(elem).find("input").each(function(i, el){
var checked = (parseInt( $j(el).val() ) & value) > 0;
$j(el).attr('checked', checked);
});
}
};
Also I need to add search fields from a subgrid.
Thanks
Most Users Ever Online: 715
Currently Online:
82 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