Solved

jQuery Flexigrid show cookie data

Posted on 2008-06-23
11
1,169 Views
Last Modified: 2010-04-21
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
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
  • 8
  • 3
11 Comments
 
LVL 8

Author Comment

by:newbie27
ID: 21845031


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
 
LVL 82

Expert Comment

by:hielo
ID: 21894397
try changing:
if( "null" !=  myList[x].id )  

to
if( null !=  myList[x].id )  
0
 
LVL 8

Author Comment

by:newbie27
ID: 21895346
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Author Comment

by:newbie27
ID: 21895456
0
 
LVL 82

Expert Comment

by:hielo
ID: 21895889
>>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
 
LVL 8

Author Comment

by:newbie27
ID: 21903023
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
 
LVL 8

Author Comment

by:newbie27
ID: 21907084
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
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
ID: 21911228
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
 
LVL 8

Author Comment

by:newbie27
ID: 21912195
yes, this is what it is happening now.
please  hielo, can you advice me how to resolve this issue.



0
 
LVL 8

Author Closing Comment

by:newbie27
ID: 31469683
thanks
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

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…
The most up-to-date version of this article is on my Blog https://iconoun.com/blog/
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…

705 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