Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1705
  • Last Modified:

jquery flexigrid not getting updated on onClick event

Hello Experts,
I have a drop down where I am displaying some name from the XML file, which ever is been selected from the drop down list box I am displaying results in the Flexigrid.
For some reason it is only functioning for the first on click event and it is not calling proxy.asp on the second click.
Please can someone advice If I am doing anything wrong here.
Many thanks for your help
Regards
Sam
0
newbie27
Asked:
newbie27
  • 5
  • 2
1 Solution
 
newbie27Author Commented:
<table id="listDisplay1" style="display:none">                              
</table>

<SELECT name="drpLists" id="drpLists"  style="width:136px; line-height:18px; padding:0; margin:4px;"
><OPTION value="0">Select List</OPTION><OPTION value="test">test</OPTION></SELECT
><script>document.frmList.hidList.value=document.frmList.drpLists[document.frmList.drpLists.selectedIndex
].value;</script>

<a href="javascript:null;" class="button" id="viewList">View List</a>                  

 function viewList(){
  if($("#drpLists").val() == 0 || $("#drpLists").val() == "new"){
    alert('Please select a list');
  }else{
   
	getListRefs();	
	var sRefNos = $("#listRefnos").val();
	  
	$('#defaultResults').hide();
    var sViewQuery = "SF1=keyword&ST1="+sRefNos; 
      
	$("#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('');  
  }
 }

Open in new window

0
 
newbie27Author Commented:
sorry the above was incorrect, i am using this to call the function
<a href="javascript:viewList();" class="button" id="viewList">
0
 
hieloCommented:
You need to double check your server script. Currently, list_proxy.asp is returning this:
 <font face="Arial" size=2>
<p>Microsoft VBScript runtime </font> <font face="Arial" size=2>error '800a0005'</font>
<p><font face="Arial" size=2>Invalid procedure call or argument: 'left'</font><p>
<font face="Arial" size=2>/artism/admin/list_proxy.asp</font><font face="Arial" size=2>, line 24</font>

which is a server-side error.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
newbie27Author Commented:
Hello Hielo,
This error has been fixed but I am not able to assign the result IDs to the query ....

getListRefs();                 --> this actually does ajax call to list_proxy.asp and i see the results back
var sRefNos = $("#listRefnos").val();  --> however i am not able to pick them from here making sRefNos empty ...

thanks


there is another question needs your help ....
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_23471788.html
 
 function getListRefs(sListname)
 {
 $.ajax({
 type: "POST",
 url: "list_builder.asp",
 data: "action=results&listname="+sListname,
 success: function(msg){
 $("#listRefnos").val( msg );
 }
});

Open in new window

0
 
hieloCommented:
The problem is that these two are called immediately in succession, one after the other:
getListRefs();
var sRefNos = $("#listRefnos").val();

getListRefs() makes an asynchronous ajax request. So, it will take some time before the request completes. Hence this:
success: function(msg){
 $("#listRefnos").val( msg );
 }

will assign msg to #listRefnos AFTER the request has completed, but the browser executes  var sRefNos = $("#listRefnos").val();  before the request is completed.

You need to call getListRefs and then provide a callback function that will then do the remaining steps AFTER the request has completed. So, you need to
modify getListRefs and viewList
create a new call back function =>viewListCallBack
 function getListRefs(sListname,callBackFunc)
 
{
 
	$.ajax({
 
	  type: "POST",
 
	  url: "list_builder.asp",
 
	  data: "action=results&listname="+sListname,
 
	  success: function(msg){
		$("#listRefnos").val( msg );		
		callBackFunc();
	  }
 
	});
 
}
 
 
function viewList(){
    
  var sListname = $("#drpLists").val();
  
  if(sListname == 0 || sListname == "new"){  
    alert('Please select a list');
  }else{
   
	getListRefs(sListname,viewListCallBack);		
 
   
  }
 }
 
function viewListCallBack()
{
	var sRefNumbers = $("#listRefnos").val();
alert( sRefNumbers)
	$('#defaultResults').hide();
    var sViewQuery = "SF1=keyword&ST1="+sRefNumbers; 
    
	listViewer("#listDisplay1",sViewQuery);
 
}

Open in new window

0
 
newbie27Author Commented:
hello hielo,
i have modified the scrpt as per your suggestion above but is giving me an error, at first it just gave me the currect number of result ids but did not update the flexigrid data ....
please can you look into this ...
thanks

http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_23486091.html
0
 
newbie27Author Commented:
thanks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now