<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title>jQuery Grid Plugin - jqGrid - Topic: Custom search field</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/custom-search-field</link>
	<description><![CDATA[Grid plugin]]></description>
	<generator>Simple:Press Version 5.7.5.3</generator>
	<atom:link href="http://www.trirand.com/blog/?page_id=393/help/custom-search-field/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>elivol on Custom search field</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/custom-search-field#p28151</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/custom-search-field#p28151</guid>
        	        	<description><![CDATA[<p>Hello</p>
<p>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.</p>
<p>Here is an element code:</p>
</p>
<p><input type='button' class='sfcodeselect' name='sfselectit8540' value='Select Code' data-codeid='sfcode8540' /></p>
<div class='sfcode' id='sfcode8540'>{name:&#39;activity_scope&#39;,index:&#39;activity_scope&#39;, width:250, editable:true, edittype:&#39;custom&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; editoptions:{<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; custom_element: function(value, options) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return Parent.getActivityScopeElement(value, options);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; custom_value: function(elem, operation, value) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return Parent.getActivityScopeValue(elem, operation, value);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; defaultValue: function() {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return 0;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; formatter: function(cellvalue, options, rowObject) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var scope = $j.parseJSON( Runtime.getParam(&#39;scope_activity&#39;)), ret = [], sum=0;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $j.extend(scope.buyer, scope.seller);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $j.each(scope.buyer, function(i, el) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if(cellvalue &#38; i) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ret.push(el) ;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; });<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return ret.slice(&#39;, &#39;) + &#39;&#60;input type=&#34;hidden&#34; value=&#34;&#39;+(cellvalue)+&#39;&#34; /&#62;&#39;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; unformat:function(cellvalue, options, rowObject) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return $j(rowObject).find(&#39;input[type=hidden]&#39;).val();<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; stype: &#39;custom&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; searchoptions: {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; sopt:[&#39;cn&#39;],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; custom_element: function(value, options) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return Parent.getActivityScopeElement(value, options);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; custom_value: function (elem, operation, value) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return Parent.getActivityScopeValue(elem, operation, value);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; sorttype:&#39;string&#39;,editrules:{custom:true, custom_func:Parent.checkActivityScope}, formoptions:{elmprefix: html.span(&#34;(*)&#34;, {&#39;class&#39;:&#39;prefix float_left&#39;})} }</div>
<p><input type='button' class='sfcodeselect' name='sfselectit586' value='Select Code' data-codeid='sfcode586' /></p>
<div class='sfcode' id='sfcode586'>&#160;&#160;&#160; this.getActivityScopeElement = function(value, options) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; var scope = $j.parseJSON( Runtime.getParam(&#39;scope_activity&#39;) );<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; var elemStr = &#39;&#60;table class=&#34;activity_scope&#34;&#62;&#60;thead&#62;&#60;tr&#62;&#60;th&#62;Buyer&#39;s side&#60;/th&#62;&#60;th&#62;Seller&#39;s side&#60;/th&#62;&#60;/tr&#62;&#60;/thead&#62;&#60;tbody&#62;&#39;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; elemStr += &#39;&#60;tr&#62;&#39;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; elemStr += &#39;&#60;td&#62;&#39;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $j.each(scope.buyer, function(i, el) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var checked = i &#38; value? &#39;checked=&#34;checked&#34;&#39; : &#39;&#39;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; elemStr += &#39;&#60;div&#62;&#60;input type=&#34;checkbox&#34; name=&#34;activity_scope&#34; value=&#34;&#39;+ i +&#39;&#34; &#39;+checked+&#39; /&#62;&#60;label&#62;&#39;+ el +&#39;&#60;/label&#62;&#60;/div&#62;&#39;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; });<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; elemStr += &#39;&#60;/td&#62;&#39;;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; elemStr += &#39;&#60;td&#62;&#39;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $j.each(scope.seller, function(i, el) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var checked = i &#38; value? &#39;checked=&#34;checked&#34;&#39; : &#39;&#39;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; elemStr += &#39;&#60;div&#62;&#60;input type=&#34;checkbox&#34; name=&#34;activity_scope&#34; value=&#34;&#39;+ i +&#39;&#34; &#39;+checked+&#39; /&#62;&#60;label&#62;&#39;+ el +&#39;&#60;/label&#62;&#60;/div&#62;&#39;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; });<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; elemStr += &#39;&#60;/td&#62;&#39;;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; elemStr += &#39;&#60;/tr&#62;&#39;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; elemStr += &#39;&#60;/tbody&#62;&#60;/table&#62;&#39;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; return $j(elemStr)[0];<br />&#160;&#160;&#160; };</p>
<p>&#160;&#160;&#160; this.getActivityScopeValue = function(elem, operation, value) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if(operation === &#39;get&#39;) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var val = 0;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $j(elem).find(&#34;input:checked&#34;).each(function(i, el){<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; val += parseInt( $j(el).val() );<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; });<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return val;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; } else if(operation === &#39;set&#39;) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $j(elem).find(&#34;input&#34;).each(function(i, el){<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var checked = (parseInt( $j(el).val() ) &#38; value) &#62; 0;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $j(el).attr(&#39;checked&#39;, checked);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; });<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160; };</p>
</div>
<p>Also I need to add search fields from a subgrid.</p>
<p>Thanks <img class="spSmiley" style="margin:0" title="Confused" src="/blog/wp-content/forum-smileys/sf-confused.gif" alt="Confused" /></p></p>
]]></description>
        	        	<pubDate>Mon, 28 Jan 2013 17:24:27 +0200</pubDate>
        </item>
</channel>
</rss>