[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

how to make a table column adjustable using jquery using the mouse?

Posted on 2011-04-30
5
Medium Priority
?
1,262 Views
Last Modified: 2012-06-21
how to make a table columns adjustable using the mouse with jquery technology?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(function(){
	$('input[type=checkbox]').bind('click',function(){
		if( this.checked)
		{
			var row=$(this).closest('tr');
			alert( row.attr('id') );
			
			alert( $('td:eq(1)', row).html() )//second cell
			alert( $('td:eq(2)', row).html() )//third cell
		}
	});	
});
</script>
</head>
<body>
<table id="theTable" border='1'>
	<tr id='rowa'><td><input type="checkbox" name="vehicle"/></td><td>a</td><td>b</td></tr> 
	<tr id='rowb'><td><input type="checkbox" name="vehicle"/></td><td>c</td><td>d</td></tr>
</table>
</body>
</html>

Open in new window

0
Comment
Question by:areyouready344
  • 3
  • 2
5 Comments
 
LVL 83

Expert Comment

by:leakim971
ID: 35499224
Check this plugin : http://www.ita.es/jquery/jquery.grid.columnSizing.htm


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
<script type="text/javascript" src="http://www.ita.es/jquery/jquery-1.1.3.1.pack.js"></script>
<script type="text/javascript" src="http://www.ita.es/jquery/jquery.dimensions.pack.js"></script>
<script type="text/javascript" src="http://www.ita.es/jquery/jquery.cookies.pack.js"></script>
<script type="text/javascript" src="http://www.ita.es/jquery/jquery.iutil.pack.js"></script>
<script type="text/javascript" src="http://www.ita.es/jquery/jquery.idrag.js"></script>
<script type="text/javascript" src="http://www.ita.es/jquery/jquery.grid.columnSizing.js"></script>
<script type="text/javascript">
$(function(){
	$("table").columnSizing()
	$('input[type=checkbox]').bind('click',function(){
		if( this.checked)
		{
			var row=$(this).closest('tr');
			alert( row.attr('id') );
			
			alert( $('td:eq(1)', row).html() )//second cell
			alert( $('td:eq(2)', row).html() )//third cell
		}
	});	
});
</script>
</head>
<body>
<table id="theTable" border='1'>
	<tr id='rowa'><td><input type="checkbox" name="vehicle"/></td><td>a</td><td>b</td></tr> 
	<tr id='rowb'><td><input type="checkbox" name="vehicle"/></td><td>c</td><td>d</td></tr>
</table>
</body>
</html>

Open in new window

leakim971-449390.flv
0
 

Author Comment

by:areyouready344
ID: 35499281
Thanks leakim but the checkbox events stop working
0
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 35499290
put back the latest jquery lib line 6 :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="http://www.ita.es/jquery/jquery.dimensions.pack.js"></script>
<script type="text/javascript" src="http://www.ita.es/jquery/jquery.cookies.pack.js"></script>
<script type="text/javascript" src="http://www.ita.es/jquery/jquery.iutil.pack.js"></script>
<script type="text/javascript" src="http://www.ita.es/jquery/jquery.idrag.js"></script>
<script type="text/javascript" src="http://www.ita.es/jquery/jquery.grid.columnSizing.js"></script>
<script type="text/javascript">
$(function(){
	$("table").columnSizing()
	$('input[type=checkbox]').bind('click',function(){
		if( this.checked)
		{
			var row=$(this).closest('tr');
			alert( row.attr('id') );
			
			alert( $('td:eq(1)', row).html() )//second cell
			alert( $('td:eq(2)', row).html() )//third cell
		}
	});	
});
</script>
</head>
<body>
<table id="theTable" border='1'>
	<tr id='rowa'><td><input type="checkbox" name="vehicle"/></td><td>a</td><td>b</td></tr> 
	<tr id='rowb'><td><input type="checkbox" name="vehicle"/></td><td>c</td><td>d</td></tr>
</table>
</body>
</html>

Open in new window

0
 

Author Comment

by:areyouready344
ID: 35499314
thanks again leakim, all is working.
0
 
LVL 83

Expert Comment

by:leakim971
ID: 35499318
You're welcome! Thanks for the points!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

830 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