Link to home
Create AccountLog in
Avatar of newbie27
newbie27Flag for United Kingdom of Great Britain and Northern Ireland

asked on

flexigrid script slight modifications

Hello Experts,
I have a piece of code which is been called twice to display data in the Flexigrid. Basically I am calling one as a default selection and another when the user picks up the choice(name) from the drop down list box to show details of the selected item in the Flexigrid.
In the other function I am having almost the same code but with very few changes, I am hoping to create one function and pass appropriate values either default or the list name.
Please can you help me in this.
Thanks
S
Avatar of newbie27
newbie27
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER


<script type="text/javascript">
 
$(document).ready(function(){
    var sRefNos = "";
     var myList = showShortList();
     for(var x=0; x<myList.length; x++){                     
         sRefNos += "," + myList[x].id  ;        
     }
     sRefNos = sRefNos.substr(1);
      
     var sQuery = "SF1=keyword&ST1="+sRefNos; 
    repopulateList();
     $("#listDisplay").flexigrid
     ({
        url: 'list_proxy.asp?a=results',       
        colModel : [                    
                        {display: '<input type="checkbox" name="chkAll" onclick="checkAll(this.checked)"/> All', name : 'chkDelete', width : 30, sortable : false, align: 'left'},
                        {display: 'Notes', name : 'notes', width : 50, sortable : false, align: 'left'},
           {display: 'Contact    ', name : 'pe_rev_name', width : 150, sortable : true, align: 'left'},
                    {display: 'Compnay Name  ', name : 'co_name', width : 200, sortable : true, align: 'left'},   
                    {display: 'Flag  ', name : 'action_flag', width : 150, sortable : true, align: 'left'},
                    {display: 'Group  ', name : 'co_group', width : 200, sortable : true, align: 'left'}                 
        ],
        buttons : [                             
                                {name: 'Delete', bclass: 'delete', onpress : removeFromList},
                                {separator: true}
                                ],                                      
        sortname: '',
        sortorder: 'asc',
        usepager: false,
        title: 'List Manager',
        useRp: true,
        rp: 1000,
        query : sQuery+'&Fields=ref_no,notes,pe_rev_name,co_name,action_flag,co_group',         
        showTableToggleBtn: true,                       
        width: 760,
        height: 350,
        onSuccess:function(){
                $(".edit_area").editable( function(value, settings) { return(value); }, 
                {     
                        submit    : "OK",
                        indicator : "process..........",
                        tooltip   : "Click to edit...",
                           style  : "inherit"
                }
                );
                                 
        }
    });    
});     
                
function viewList(){
  if($("#drpLists").val() == 0 || $("#drpLists").val() == "new"){
    alert('Please select a list');
  }else{
   
        getListRefs();  
        var sRefNumbers = $("#listRefnos").val();       
        $('#defaultResults').hide();
    var sViewQuery = "SF1=keyword&ST1="+sRefNumbers; 
      
        $("#listDisplay1").flexigrid     
     ({
        url: 'list_proxy.asp?a=results',       
        colModel : [                    
                        {display: '<input type="checkbox" name="chkAll" onclick="checkAll(this.checked)"/> All', name : 'chkDelete', width : 30, sortable : false, align: 'left'},
                        {display: 'Notes', name : 'notes', width : 50, sortable : false, align: 'left'},
           {display: 'Contact    ', name : 'pe_rev_name', width : 150, sortable : true, align: 'left'},
                    {display: 'Compnay Name  ', name : 'co_name', width : 200, sortable : true, align: 'left'},   
                    {display: 'Flag  ', name : 'action_flag', width : 150, sortable : true, align: 'left'},
                    {display: 'Group  ', name : 'co_group', width : 200, sortable : true, align: 'left'}                 
        ],
        buttons : [                             
                                {name: 'Delete', bclass: 'delete', onpress : removeFromList},
                                {separator: true}
                                ],                                      
        sortname: '',
        sortorder: 'asc',
        usepager: false,
        title: 'View List Manager',
        useRp: true,
        rp: 100,
        query : sViewQuery+'&Fields=ref_no,notes,pe_rev_name,co_name,action_flag,co_group',         
        showTableToggleBtn: true,                       
        width: 760,
        height: 350,
        onSuccess:function(){
                $(".edit_area").editable( function(value, settings) { return(value); }, 
                {     
                        submit    : "OK",
                        indicator : "process..........",
                        tooltip   : "Click to edit...",
                           style  : "inherit"
                }
                );
                                 
        }
    });  
    $("#listRefnos").val('');  
  }
 }
</script>

Open in new window

function showListDetails(sListName)
{}

showListDetails(cookieName)

Or

showListDetails(existingListName)

can we make the above in one function hielo? please advice ...  

I dont want to display anything if there neither cookie name or list name exist

thanks for your help
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
thanks hielo,
query for both these calls are different Hielo, can you please help me in passing appropriate query to the function here

https://www.experts-exchange.com/questions/23483765/jquery-passing-parameters.html

thanks
sam
thanks