jQuery show results in the Flexigrid on the user selection

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
LVL 8
newbie27Asked:
Who is Participating?
 
hieloConnect With a Mentor Commented:
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
 
newbie27Author Commented:
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
 
newbie27Author Commented:
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
 
newbie27Author Commented:
thnaks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.