3 * jqGrid extension for manipulating columns properties
\r
4 * Piotr Roznicki roznicki@o2.pl
\r
5 * http://www.roznicki.prv.pl
\r
6 * Dual licensed under the MIT and GPL licenses:
\r
7 * http://www.opensource.org/licenses/mit-license.php
\r
8 * http://www.gnu.org/licenses/gpl.html
\r
11 setColumns : function(p) {
\r
19 closeicon: 'ico-close.gif',
\r
20 beforeShowForm: null,
\r
21 afterShowForm: null,
\r
22 afterSubmitForm: null
\r
23 }, $.jgrid.col, p ||{});
\r
24 return this.each(function(){
\r
26 if (!$t.grid ) { return; }
\r
27 var onBeforeShow = typeof p.beforeShowForm === 'function' ? true: false;
\r
28 var onAfterShow = typeof p.afterShowForm === 'function' ? true: false;
\r
29 var onAfterSubmit = typeof p.afterSubmitForm === 'function' ? true: false;
\r
30 if(!p.imgpath) { p.imgpath= $t.p.imgpath; } // Added From Tony Tomov
\r
31 var gID = $("table:first",$t.grid.bDiv).attr("id");
\r
32 var IDs = {themodal:'colmod'+gID,modalhead:'colhd'+gID,modalcontent:'colcnt'+gID};
\r
33 var dtbl = "ColTbl_"+gID;
\r
34 if ( $("#"+IDs.themodal).html() != null ) {
\r
35 if(onBeforeShow) { p.beforeShowForm($("#"+dtbl)); }
\r
36 viewModal("#"+IDs.themodal,{modal:p.modal});
\r
37 if(onAfterShow) { p.afterShowForm($("#"+dtbl)); }
\r
39 var tbl =$("<table id='"+dtbl+"' class='ColTable'><tbody></tbody></table>");
\r
40 for(i=0;i<this.p.colNames.length;i++){
\r
41 if(!$t.p.colModel[i].hidedlg) { // added from T. Tomov
\r
42 $(tbl).append("<tr><td ><input type='checkbox' id='col_" + this.p.colModel[i].name + "' class='cbox' value='T' " +
\r
43 ((this.p.colModel[i].hidden==undefined)?"checked":"") + "/>" + "<label for='col_" + this.p.colModel[i].name + "'>" + this.p.colNames[i] + "(" + this.p.colModel[i].name + ")</label></td></tr>");
\r
46 var bS ="<input id='dData' type='button' value='"+p.bSubmit+"'/>";
\r
47 var bC ="<input id='eData' type='button' value='"+p.bCancel+"'/>";
\r
48 $(tbl).append("<tr><td class='ColButton'>"+bS+" "+bC+"</td></tr>");
\r
49 createModal(IDs,tbl,p,$t.grid.hDiv,$t.grid.hDiv);
\r
50 if( p.drag) { DnRModal("#"+IDs.themodal,"#"+IDs.modalhead+" td.modaltext"); }
\r
51 $("#dData","#"+dtbl).click(function(e){
\r
52 for(i=0;i<$t.p.colModel.length;i++){
\r
53 if(!$t.p.colModel[i].hidedlg) { // added from T. Tomov
\r
54 if($("#col_" + $t.p.colModel[i].name).attr("checked")) {
\r
55 $($t).showCol($t.p.colModel[i].name);
\r
56 $("#col_" + $t.p.colModel[i].name).attr("defaultChecked",true); // Added from T. Tomov IE BUG
\r
58 $($t).hideCol($t.p.colModel[i].name);
\r
59 $("#col_" + $t.p.colModel[i].name).attr("defaultChecked",""); // Added from T. Tomov IE BUG
\r
63 $("#"+IDs.themodal).jqmHide();
\r
64 if (onAfterSubmit) { p.afterSubmitForm($("#"+dtbl)); }
\r
67 $("#eData", "#"+dtbl).click(function(e){
\r
68 $("#"+IDs.themodal).jqmHide();
\r
71 if(onBeforeShow) { p.beforeShowForm($("#"+dtbl)); }
\r
72 viewModal("#"+IDs.themodal,{modal:p.modal});
\r
73 if(onAfterShow) { p.afterShowForm($("#"+dtbl)); }
\r