Solved

jquery flexigrid not getting updated on onClick event

Posted on 2008-06-10
7
1,650 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

Containers and Docker for Everyone

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

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

This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

688 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