Posts

Showing posts from September, 2013

Selecting all check box in a Table row or column

During one of my assignment I’ve come across a requirement to selecting all the checkboxes in a row or column of table. Accomplishing this task using server side code is really very difficult and need hard coding. So, I’ve come across idea of using jquery. Jquery is really very powerful, and it contains filters and selectors that we can use to select checkboxes. In the process of selecting checkboxes first step is to recognize whether user want to select row or column. So, I tried to get the parent of checkbox i.e. TH or TD. If it’s a TH then selecting column otherwise row. Case 1: Selecting row Selecting row is very simple, by this time you already have instance of TD then by using parent selected we can get the TR of that row.  And once we get TR then selecting checkboxes is piece of cake. Below is the code to select checkboxes. tr.find( 'input[type=checkbox]' ).attr( 'checked' , this .checked); Case 2: Selecting Columns Selecting column is little difficult t