jQuery Flexigrid show cookie data

Hello Experts,
I am using jquery flexigrid to show data from the cookie. It is displaying the data correctly as a default result set. But then when I want to view it manually by selecting the cookie name from the drop down, this function is not showing the Flexigrid at all. Although the Ajax is returning correct data required.
Please can someone of you look into this.
Thanks
Sam
LVL 8
newbie27Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
hieloConnect With a Mentor Commented:
In list_admin.asp you have:
$(document).ready(function()
{
  repopulateList("shortlist");  
});

and if you look at repopulateList() you have:

sDrpListName = $("#drpLists").val();
$.ajax(...);

There's not way that will work. When the page first loads, there is no #drpLists.
That list is dynamically retrieved by the $.ajax() request that follows. Hence,
sDrpListName = $("#drpLists").val(); will return undefined.
0
 
newbie27Author Commented:


function showCookieList(){
       var sRefNos = "";
		var myList = showShortList();
     	for(var x=0; x<myList.length; x++)
		{    if( "null" !=  myList[x].id )                
         		sRefNos += "," + myList[x].id  ;        
     	}
     	sRefNos = sRefNos.substr(1);
      
     	var sQuery = "SF1=keyword&ST1="+sRefNos; 
		alert(sQuery);
    	$('#flexicontainer').html('<table id="listDisplay" style="display:none"></table>'); 
		listViewer("#listDisplay", sQuery);		
}  
		
 
 
//this actually fills in the flexigrid table.
function listViewer(listID, param1)
{      
		$(listID).flexigrid
		({
        		url: 'list_proxy.asp?a=results',       
        		colModel : [                                     				
					    //{display: '<input type="checkbox" name="chkAll" onclick="checkAll(&#39;#listDisplay&#39;)"/> All', width : 30},
						//{display: '', width : 30},						
						{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 : 50, sortable : true, align: 'left'},
                    	{display: 'Group  ', name : 'co_group', width : 150, sortable : true, align: 'left'},                 
						{display: 'Notes', name : 'notes', width : 200, sortable : false, align: 'left'}
        			],
        		buttons : [                             
                         {name: 'Save', bclass: 'add', onpress : test},	
						 {name: 'Remove', bclass: 'delete', onpress : test},					                
						 {name: 'Export', bclass: 'add', onpress : test},							 
						 {name: 'Merge', bclass: 'add', onpress : test},	
						 {name: 'DeSelect All', bclass: 'delete', onpress : test},	
						 {name: 'Select All', bclass: 'add', onpress : test},	
						 
                  	],                                      
        		sortname: '',
        		sortorder: 'asc',
        		usepager: false,
        		title: 'List Name - ' + $("#drpLists").val(),
        		useRp: true,
        		rp: 1000,
        		query : param1+'&Fields=ref_no,pe_rev_name,co_name,action_flag,co_group,notes',         
        		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" ,
							type      : "textarea",
   						    indicator : "<img src='images/indicator.gif'>"
 
 
                			}
					);
				}
        		
        	});
 
}

Open in new window

0
 
hieloCommented:
try changing:
if( "null" !=  myList[x].id )  

to
if( null !=  myList[x].id )  
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
newbie27Author Commented:
hello hielo,
please add few items to the shortlist and try picking from the drop down...it is is not not showing the shortlist details in the grid
0
 
newbie27Author Commented:
0
 
hieloCommented:
>>please add few items to the shortlist and try picking from the drop down...it is is not not showing the shortlist details in the grid
I added items, clicked save. On the other page I picked a different item from the select list, clicked on view list and the old grid data disappeared and a new data showed on flexigrid. I tried FF and IE6. I can't recreate the problem. Perhaps you are not accepting cookies?
0
 
newbie27Author Commented:
hello hielo,
thanks for looking into this for me, i am accepting cookies hielo, but the problem is not first time you view the list.

>> I added items, clicked save. On the other page I picked a different item from the select list, clicked on view list and the old grid data disappeared and a new data showed on flexigrid

this is ok hielo, the problem, is 1) when you add new item to the list, after saving the list by some name the grid is not holding the newly added list, rather it is defaulting to shortlist data.

2)  when you pick any list from the drop down, it is showing the data correctly in the grid but when I now chose the shortlist from the drop down, the cookie list is not been displayed..

i hope you see the problem here?

thanks alot for your help

regards
sam
0
 
newbie27Author Commented:
for my second problem, it is not showing the grid from the showCookieList function Hielo.

showCokieList function calling listViewer function and passing ID and Param1 correctly but the flexigrid is still seems to be hidden...

please can you help me

thanks
sam

function getListRefs(sListname)
{       
       
		if(sListname == "shortlist"){
			//alert('getListRefs='+sListname);
			if( $.cookie('shortlist') )    
         
                showCookieList();
				
				$("#txtListName").val('ShortList');
				$("#txtNotes").val('');
        }else{ 
			$.ajax({
			  type: "POST",
			  url: "list_builder.asp",
			  data: "action=results&listname="+sListname,
			  success: function(xml)
							{								
								/*var errCode = $("errorcode",xml).text();
								var errMsg  = $("errormsg",xml).text();
								var rsTexts  = $("responsetext",xml).text();*/
								var temp    = xml.split("|");
								var sName = temp[0];      // List Name
								var sNotes =temp[1];      // List Notes
								var sIds = temp[2];	   // List RefNos 
								 
								//alert(xml);
								if(sIds){
								  // alert('sIds=' + sIds);
										var sRefNumbers = $("#listRefnos").val();
										//alert(sRefNumbers);
										var sViewQuery = "SF1=keyword&ST1="+sRefNumbers; 
										//alert(sViewQuery);
										listViewer("#listDisplay",sViewQuery);										
										$("#txtListName").val(sName);
										$("#txtNotes").val(sNotes);									
								}
							}
			});
		}	
} 
 
 
 
function showCookieList(){
       var sRefNos = "";
		var myList = showShortList();
     	for(var x=0; x<myList.length; x++)
		{    //if( "null" !=  myList[x].id )                
			if( null !=  myList[x].id )  
         		sRefNos += "," + myList[x].id  ;        
     	}
     	sRefNos = sRefNos.substr(1);
      
     	var sQuery = "SF1=keyword&ST1="+sRefNos; 
		alert(sQuery);
    	$('#flexicontainer').html('<table id="listDisplay" style="display:none"></table>'); 
		listViewer("#listDisplay", sQuery);		
}  
 
 
function listViewer(listID, param1)
{       alert(listID + ' ' + param1);
		$(listID).flexigrid
		({
        		url: 'list_proxy.asp?a=results',       
        		colModel : [                                     				
						{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 : 50, sortable : true, align: 'left'},
                    	{display: 'Group  ', name : 'co_group', width : 150, sortable : true, align: 'left'},                 
						{display: 'Notes', name : 'notes', width : 200, sortable : false, align: 'left',process:showNotes}
        			],
        		buttons : [                             
                         {name: 'Save ', bclass: 'save', onpress : test},	
						 {name: 'Remove ', bclass: 'remove', onpress : test},					                
						 {name: 'Export ', bclass: 'export', onpress : test},							 
						 {name: 'Merge ', bclass: 'merge', onpress : test},	
						 {name: 'DeSelect All', bclass: 'deselect', onpress : test},	
						 {name: 'Select All', bclass: 'select', onpress : test},	
						 
                  	],                                      
        		sortname: '',
        		sortorder: 'asc',
        		usepager: false,
        		title: 'List Name - ' + $("#drpLists").val(),
        		useRp: true,
        		rp: 1000,
        		query : param1+'&Fields=ref_no,pe_rev_name,co_name,action_flag,co_group,notes',         
        		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" ,
							type      : "textarea",
   						    indicator : "<img src='images/indicator.gif'>"
 
 
                			}
					);
				}
        		
        	});
 
}
 

Open in new window

0
 
newbie27Author Commented:
yes, this is what it is happening now.
please  hielo, can you advice me how to resolve this issue.



0
 
newbie27Author Commented:
thanks
0
All Courses

From novice to tech pro — start learning today.