Solved

jQuery show results in the Flexigrid  on the user selection

Posted on 2008-06-13
4
431 Views
Last Modified: 2010-04-21
Hello Folks,
I am making Flexigrid to receive data dynamically by amending param:query based on the user selection.
User has a choice to pick item name from the dynamically populated list which includes the default cookie name and list names from the xml file.
All I wanted to do here is whichever name been selected, make a query, do an ajax request and assign the response to the Flexigrid. Please have my code snippet attached .
Thanks for your help
Regards
Sam
0
Comment
Question by:newbie27
  • 3
4 Comments
 
LVL 8

Author Comment

by:newbie27
ID: 21782765
Hopefully you may understand what I am trying to say you here If you please see the code attached,

List html data being generated
-------------------------------------
<SELECT name="drpLists" id="drpLists" style="width:136px; line-height:18px; padding:0; margin:4px;">
<OPTION value="0">Select List</OPTION>
<OPTION value="shortlist" selected> Temp List</OPTION>
<OPTION value="test" >test</OPTION>
<OPTION value="new">New List...</OPTION>
</SELECT>

In here the default selection is Temp List which is a cookie by name "shortlist"

so when I call this function
function listViewer(listID, param1)
{}

I either want to display data for "shortlist" or "test"

I want to modify my code to do as desired above, ie
whichever selected show the data in the Flexigrid

perhaps i need to pass another parameter for the listname?

function listViewer(listID, param1,param2?)
{}

Can I not use one listID for these calls anyway? if so then i would not need a parameter for listID.
Other third parameter for the listname...
listViewer("#listDisplay" , sQuery,'shortlist');

Please can you advice me here....

I am sure I have not explained it will but I hope you may understand it !

many thanks for your help and time.





This is the default call

------------------------

$(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();

		listViewer("#listDisplay" , sQuery);

	

});     
 

to this function

----------------

function listViewer(listID, param1)

{

     	$(listID).flexigrid

		({

        		url: 'list_proxy.asp?a=results',       

        		colModel : [                    

                        	{display: ' ', name : 'chkDelete', width : 30, sortable : false, align: 'left'},

					//{display: '<input type="checkbox" name="chkAll" onclick="checkAll(this.checked)"/> All', width : 30},

                        	{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 : test},

					//	{name: 'Select All', bclass: 'add', onpress : test},

					//{name: 'DeSelect All', bclass: 'delete', onpress : test}

                                

                  	],                                      

        		sortname: '',

        		sortorder: 'asc',

        		usepager: false,

        		title: 'List Manager - Titles',

        		useRp: true,

        		rp: 1000,

        		query : param1 +'&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",

							callback  : function (value, settings){if ($(this).hasClass('trSelected')){alert('selected');}	}

                			}

					);

				}

        	});

 

}
 

once the user select the list name, he would click on the show list button to view the detailed for the selected item ...
 

i am calling this function from button onclick

-------------------------------------------------

function viewList(){

    

  var sListname = $("#drpLists").val();

  

  if(sListname == 0 || sListname == "new"){  

    alert('Please select a list');

  }else{

   

	getListRefs(sListname);		

	var sRefNumbers = $("#listRefnos").val();

	

	$('#defaultResults').hide();

    var sViewQuery = "SF1=keyword&ST1="+sRefNumbers; 

    

	listViewer("#listDisplay1",sViewQuery);

 

   

  }

 }

Open in new window

0
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
ID: 21785532
Since your <SELECT> is the result of an ajax call, you need an onSuccess event handler for that call that will find the selected option and then make the ajax request for the flexigrid control.
0
 
LVL 8

Author Comment

by:newbie27
ID: 21788309
Hello Hielo,
I have treid but it did not work... can you please help me on this
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_23486088.html

  function repopulateList()

{

	$.ajax({

	  type: "POST",

	  url: "list_builder.asp",

	  data: "action=save&listname="+$("#txtListName").val(),

	  success: function(msg){

							$("#theList").html( msg );								

                            }

    });

}

Open in new window

0
 
LVL 8

Author Closing Comment

by:newbie27
ID: 31467081
thnaks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

863 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

20 Experts available now in Live!

Get 1:1 Help Now