Link to home
Start Free TrialLog in
Avatar of newbie27
newbie27Flag for United Kingdom of Great Britain and Northern Ireland

asked on

how to call these two functions

Hello Experts,

I have these two functions on the checkbox I am using in the attached function.


if(listID)=="#listDisplay"
  {display: '<input type="checkbox" name="chkAll" onclick="checkAllDefault(this.checked)"/> All', width : 30},
else
 {display: '<input type="checkbox" name="chkAll" onclick="checkAllDynamic(this.checked)"/> All', width : 30},

I have tried to do a check and apply the checkbox to the listViewer function but it did not work.

Please can you help.

Thanks
S


Avatar of newbie27
newbie27
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

please have the top two function which I wanted to use listViewer

thanks for your help

function checkAllDefault(chkd)
{
      $("#listDisplay1 > tbody > tr > td > div > input.chkRefNos").each(function(){
                this.checked = chkd;
            });
}
 
 
function checkAllDynamic(chkd)
{
      $("#listDisplay > tbody > tr > td > div > input.chkRefNos").each(function(){
                this.checked = chkd;
            });
}
 
---------------------------------- 
 
 
function listViewer(listID, param1)
{     
     	$(listID).flexigrid
		({
        		url: 'list_proxy.asp?a=results',       
        		colModel : [                    
	{display: '<input type="checkbox" name="chkAll" onclick="checkAllDefault(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 - ' + $("#drpLists").val(),
        		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" 
                			}
					);
				}
        		
        	});
 
}

Open in new window

Avatar of hielo
Try having a single function that takes an id parameter:
function checkAll(id )
{
      $( id +" > tbody > tr > td > div > input.chkRefNos").each(function(){
                this.checked = chkd;
            });
}

and then your checkboxes would be:
if(listID)=="#listDisplay"
  {display: '<input type="checkbox" name="chkAll" onclick="checkAll(\'#listDisplay\')"/> All', width : 30},
else
 {display: '<input type="checkbox" name="chkAll" onclick="checkAll(\'#listDisplay1\')"/> All', width : 30},
I am getting syntax error here Hielo.

if(listID)=="#listDisplay"   ---> this line
                              {display: '<input type="checkbox" name="chkAll" onclick="checkAll(\'#listDisplay\')"/> All', width : 30},
                              else
                              {display: '<input type="checkbox" name="chkAll" onclick="checkAll(\'#listDisplay1\')"/> All', width : 30},
                        
syntax error
[Break on this error] if(listID)=="#listDisplay"\n

Open in new window

instead of \' use &#39;

if(listID)=="#listDisplay"   ---> this line
                              {display: '<input type="checkbox" name="chkAll" onclick="checkAll(&#39;#listDisplay&#39;)"/> All', width : 30},
                              else
                              {display: '<input type="checkbox" name="chkAll" onclick="checkAll(&#39;#listDisplay1&#39;)"/> All', width : 30},
I have Hielo, apparently it is still giving the same error
syntax error
[Break on this error] if(listID)=="#listDisplay" \n

Open in new window

I think we cannot add any condition within that block in Flexigrid,...? I guess ...
>>I think we cannot add any condition within that block ..
COrrect. You have to do the if outside of that block.
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OK Hielo,
I have done something like this but still says the same

please see for "chkShow"
 var chkShow;
		if(listID)=="#listDisplay"  
           chkShow = '<input type="checkbox" name="chkAll" onclick="checkAll(&#39;#listDisplay&#39;)"/> All';
       else
           chkShow = '<input type="checkbox" name="chkAll" onclick="checkAll(&#39;#listDisplay1&#39;)"/> All';
 
		$(listID).flexigrid
		({
        		url: 'list_proxy.asp?a=results',       
        		colModel : [                    
                 	    {display: chkShow, width : 30},

Open in new window

yes this has worked...thanks
                   colModel : [                    
                  //   {display: ' ', name : 'chkDelete', width : 30, sortable : false, align: 'left'},
                           {display: ( listID=="#listDisplay" ? '<input type="checkbox" name="chkAll" onclick="checkAll(&#39;#listDisplay&#39;)"/> All' : '<input type="checkbox" name="chkAll" onclick="checkAll(&#39;#listDisplay1&#39;)"/> 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'}                
                          ],