Solved

flexigrid script slight modifications

Posted on 2008-06-12
5
255 Views
Last Modified: 2012-06-21
Hello Experts,
I have a piece of code which is been called twice to display data in the Flexigrid. Basically I am calling one as a default selection and another when the user picks up the choice(name) from the drop down list box to show details of the selected item in the Flexigrid.
In the other function I am having almost the same code but with very few changes, I am hoping to create one function and pass appropriate values either default or the list name.
Please can you help me in this.
Thanks
S
0
Comment
Question by:newbie27
  • 4
5 Comments
 
LVL 8

Author Comment

by:newbie27
ID: 21771223

<script type="text/javascript">

 

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

     $("#listDisplay").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: 'List Manager',

        useRp: true,

        rp: 1000,

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

                }

                );

                                 

        }

    });    

});     

                

function viewList(){

  if($("#drpLists").val() == 0 || $("#drpLists").val() == "new"){

    alert('Please select a list');

  }else{

   

        getListRefs();  

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

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

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

      

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

  }

 }

</script>

Open in new window

0
 
LVL 8

Author Comment

by:newbie27
ID: 21771294
function showListDetails(sListName)
{}

showListDetails(cookieName)

Or

showListDetails(existingListName)

can we make the above in one function hielo? please advice ...  

I dont want to display anything if there neither cookie name or list name exist

thanks for your help
0
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
ID: 21781603
Try:
<script type="text/javascript">
 

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

	

});     

                

function listViewer(listID)

{

     	$(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 : sQuery+'&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');}	}

                			}

					);

				}

        	});
 

}
 

function test(com,grid)

            {

                if (com=='Delete')

					{

						if($('.trSelected',grid).length <= 0){ alert('You have not selected any item.');

						}else{

					   if(confirm('Do you want to delete the selected ' + $('.trSelected',grid).length + ' item(s)?')){

						var items = $('.trSelected',grid);

						var itemlist ='';

						for(i=0;i<items.length;i++){

							//itemlist+= items[i].id.substr(3)+",";	

                        // $(".chkRefNos").checked();				

							removeShortList("shortlist", items[i].id.substr(3));

						}						

						  window.location.reload(true);

						  $("#listDisplay").flexReload();

						

						}}

					}

                else if (com=='Select All'){

						$('.bDiv tbody tr',grid).addClass('trSelected');

				  }else if (com=='DeSelect All'){

						$('.bDiv tbody tr',grid).removeClass('trSelected');

				  }          

            } 

				
 
 

function removeFromList(){

    var result = "";                        

    $(".chkRefNos").each( function () {

      //if(this.checked == true) {             

        removeCookieItem(this);   

     //} 

    });	

	 window.location.reload(true);    

} 

	

				

function viewList(){

    

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

  

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

    alert('Please select a list');

  }else{

   

	getListRefs(sListname);	

	//alert("listRefnos=" + $("#listRefnos").val());

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

	

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

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

     // alert(sListname + " : " + sViewQuery);

	listViewer("#listDisplay1");
 
 

/*

	$("#listDisplay1").flexigrid	 

     ({

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

        colModel : [                                        

						   {display: '', name : '', width : 30, 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 - Titles',

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

  }

 }

</script>

Open in new window

0
 
LVL 8

Author Comment

by:newbie27
ID: 21781747
thanks hielo,
query for both these calls are different Hielo, can you please help me in passing appropriate query to the function here

http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_23483765.html

thanks
sam
0
 
LVL 8

Author Closing Comment

by:newbie27
ID: 31466623
thanks
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

Suggested Solutions

Title # Comments Views Activity
rhino JavaScript import, load 25 67
jQuery AJAX Redirects Without Response/Error 10 46
Animated .jpg? 13 60
Show/Hide ASP.NET controls with JQuery best practices 3 18
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article discusses how to create an extensible mechanism for linked drop downs.
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

15 Experts available now in Live!

Get 1:1 Help Now