Solved

jquery flexigrid not getting updated on onClick event

Posted on 2008-06-10
7
1,635 Views
Last Modified: 2012-06-27
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
Comment
Question by:newbie27
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
7 Comments
 
LVL 8

Author Comment

by:newbie27
ID: 21749794
<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
 
LVL 8

Author Comment

by:newbie27
ID: 21749800
sorry the above was incorrect, i am using this to call the function
<a href="javascript:viewList();" class="button" id="viewList">
0
 
LVL 82

Expert Comment

by:hielo
ID: 21783982
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Author Comment

by:newbie27
ID: 21784990
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
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
ID: 21785456
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
 
LVL 8

Author Comment

by:newbie27
ID: 21788356
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
 
LVL 8

Author Closing Comment

by:newbie27
ID: 31465674
thanks
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need help with this homework problem. 5 58
Table doesn't show the lines! 3 24
Put POST values into cookies. 14 34
calculate days away 11 26
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question