Forum

November 2nd, 2014
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_Related Related Topics sp_TopicIcon
Custom search field
28/01/2013
17:24
Avatar
elivol
Israel
Member
Members
Forum Posts: 15
Member Since:
01/06/2010
sp_UserOfflineSmall Offline

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:

{name:'activity_scope',index:'activity_scope', width:250, editable:true, edittype:'custom',
                    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'})} }

    this.getActivityScopeElement = function(value, options) {
        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 Confused

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
34 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