Solved

jquery flexigrid not getting updated on onClick event

Posted on 2008-06-10
7
1,607 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
  • 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Close "X" button on window popup in Firefox 7 37
XML XSL Message 3 14
Auto refresh part of an MVC5 View 7 59
Randomize in Owl Carousel v1.3.2 6 20
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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now