0

I Have a problem in the reset, as you see i have set the status default as ACTIVE, and only one record can be selected, after selecting the record user can click ADD WO

http://i48.tinypic.com/11udoo6.jpg

But when click on the Reset button the whole status bar changes

http://i45.tinypic.com/25a6vcp.jpg

I also set the dafaultvalue to ACTIVE also..!! I Have to keep the status active, when it resets..!!Plz help me

function initJqGridSearchSubProject(table,pager,msg,loadSelID,caption,chkMrk ){

 $(table).empty();
 $(table).GridUnload();
 var mygrid =jQuery(table).jqGrid({
    datatype: "local",      
    data:msg,   
    width: 1240,
    scrollOffset:0,     
    height: 250,
    colNames:['ID','PID','Project Folder Name','Sub Project Name','Responsible','Status','Last Updated On'],
    colModel:[
    {name:'id',index:'id',hidden:true, width:5, sorttype:"int", editable: false,resizable:false},
    {name:'pid',hidden:true, width:5, sorttype:"int", editable: false,resizable:false},
    {name:'projectFolderName', width:250, editable: true,formatter:'tsLinks'},
    {name:'subProjectName', width:250, editable: true,formatter:'subProjectLinks'},
    //{name:'eCNNumber', width:150, editable: true},                
    {name:'responsible', width:200, editable:false,resizable:false},
    {name:'status', width:100,editable: true,stype:'select',edittype:"select",resizable:false,searchoptions:{defaultValue:"ACTIVE"},editoptions:{value:"ACTIVE:ACTIVE;INACTIVE:INACTIVE;DELETED:DELETED",readonly:false},editrules:{edithidden:false}}, 
    {name:'lastUpdatedOn', width:200,editable: false,resizable:false,sorttype:'date',formatter:'date',formatoptions:{ srcformat: 'M d y H:i:s', newformat: 'd M y h:i A' }}

        ],
    pager: pager,
    rowNum:200,     
    rowList:[200,400,600,1000],
    //rowTotal:2000,                    
    //loadOnce:true,    
    //rownumbers:true,
    gridview : true,
    sortname: 'lastUpdatedOn',                  
    viewrecords: true,
    sortorder: "desc",                  
    toppager:true,
    multiselect:true,
    singleselect: false, 
    //multiboxonly:true,
    //toolbar: [true,'both'],                   
    caption:caption,
    hidegrid: false,
    gridComplete:function(id){
    //$(chkMrk).hide();
    //alert('grid complete');
    },
    beforeSelectRow: function(rowid, e)
    {
        // reset check box selection only when user clicks on another checkbox
        if($(e.target).is("input:checkbox"))
        {
            // reset/clear other checkboxes selection before making a latest clicked row's checkbox as selected
            jQuery(table).jqGrid('resetSelection');
        }

        // Code To Disable Check Box Selection When User Selects by Clicking on A Row
        return $(e.target).is("input:checkbox");
        //return(true);
    }

}); 
jQuery(table).jqGrid('navGrid',pager,{del:false,add:false,edit:false,search:false,refresh:true,cloneToTop:true,afterRefresh:function(){}},{},{},{},{}); 
jQuery(table).jqGrid('navButtonAdd', table+ '_toppager_left',{caption:"Add WO", buttonicon:"ui-icon ui-icon-plus",id:"SUBPROJID", onClickButton: function(){},position:"first",title:"Add WO"});

2 Answers2

0

What you have done is that you have set the defaultValue option in searchoptions and not in editoptions. You just have to add the same there. Just try changing the definition of status column as below :

{name:'status', width:100,editable: true,stype:'select',edittype:"select",
resizable:false,searchoptions:{defaultValue:"ACTIVE"},
editoptions:{value:"ACTIVE:ACTIVE;INACTIVE:INACTIVE;DELETED:DELETED",
readonly:false, defaultValue:"ACTIVE"},editrules:{edithidden:false}},

Update :

To call the line inside of beforeRefresh event handler you can do as follows :

jQuery(table).jqGrid('navGrid',pager,
  { edit:false,view:false,add:false,del:false,search:false,
    beforeRefresh: function(){
        alert('Here');
        jQuery(table).jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid');
    }
  });
Ajo Koshy
  • 1,205
  • 2
  • 21
  • 33
  • Still am getting the same issue...i think there's something to do with the reset..should we declare any function..??? – Sendhil Kumar Apr 04 '13 at 05:15
  • Can we set the defaultValue: ACTIVE in reset button..? – Sendhil Kumar Apr 04 '13 at 05:17
  • I dont think so. when `refresh` is set to `true` a reset button is a result on the toolbar.When the button is clicked a `trigger(“reloadGrid”)` is executed and the search parameters are cleared – Ajo Koshy Apr 04 '13 at 05:17
  • If you need to do some actions before refresh will be started you should use `beforeRefresh` callback: `$("#grid_id").jqGrid('navGrid', '#gridpager', {` `beforeRefresh: function () {` `// some code here` `}` `});` Else you should set `refresh : false` and use your own custom button – Ajo Koshy Apr 04 '13 at 05:20
  • So shall i remove the searchoptions in the status row? – Sendhil Kumar Apr 04 '13 at 05:23
  • That would just not set the value to 'ACTIVE' as default – Ajo Koshy Apr 04 '13 at 05:24
  • 'jQuery(table).jqGrid('navGrid',pager,{del:false,add:false,edit:false,search:false,beforeRefresh: function(){ alert('beforeRefresh'); grid.jqGrid('setGridParam',{datatype:'local'}).trigger('reloadGrid'[{current:true}]); },cloneToTop:true,afterRefresh:function(){}},{},{},{},{}); ' Its not Happening..the page is not refreshing..?? – Sendhil Kumar Apr 04 '13 at 05:42
  • Outside the line! in the sense..we should use it outside reset button..? – Sendhil Kumar Apr 04 '13 at 05:51
  • i was trying for beforerefresh like this http://stackoverflow.com/questions/3772334/how-to-get-jqgrid-reload-to-go-to-server – Sendhil Kumar Apr 04 '13 at 06:04
  • tried giving beforeRefresh as you said but still the issue persists,the checkbox is being checked.when i press the reset button. – Sendhil Kumar Apr 04 '13 at 06:28
0

Finally got the result, i just added the triggerToolbar() inside the reset button function.

jQuery(table).jqGrid('navGrid',pager,{del:false,add:false,edit:false,search:false,refresh:true,cloneToTop:true,afterRefresh:function(){$(table)[0].triggerToolbar();}},{},{},{},{});

And now its working fine..!