2

For example I selected (checked) 2 rows from second page than go to first page and select 3 rows. I want get information from 5 selected rows when I stay at first page.

$('tr.row_selected') - not working

Thanks.

Upd.

I created handler somthing like this:

$('#example').find('tr td.sel-checkbox').live("click", function () { /*code here*/ });

But right now when click event is hadle the row from table is hidding. I think it may be sorting or grouping operation of DataTables. Any idea what I must do with this?

2
  • Please provide code or jsfiddle Commented Jan 14, 2013 at 15:28
  • It is default configuration of datatables plugin. Nothing special. I can't find standart function for this operation and can't apply JQuery methods for it. Commented Jan 14, 2013 at 16:31

2 Answers 2

3

When a checkbox gets selected, store the row information you want in a global object as a Key-Value pair

I don't remember specifically how i did it before but the syntax was something like

$('input[type=checkbox]').click(function()
{
    var row = $(this).parent(); //this or something like it, you want the TR element, it's just a matter of how far up you need to go
    var columns = row.children(); //these are the td elements

    var id = columns[0].val(); //since these are TDs, you may need to go down another element to get to the actual value

    if (!this.checked) //becomes checked (not sure may be the other way around, don't remember when this event will get fired)
    {
        var val1 = columns[1].val();
        var val2 = columns[2].val();

        myCheckValues[id] =[val1,val2]; //Add the data to your global object which should be declared on document ready
    }
    else delete myCheckValues[id];
});

When you submit, get the selected rows from your object:

for (var i = 0; i < myCheckValues.length; i++)
...

Sorry, haven't done JS in a long time so code as is might not work but you get the idea.

Sign up to request clarification or add additional context in comments.

Comments

3
$('#example').find('tr td.sel-checkbox').live("click", function () {
            var data = oTable.fnGetData(this);
            // get key and data value from data object
            var isSelected = $(this).hasClass('row_selected');
            if(isSelected) {
                myCheckValues[key] = value;
                checkedCount++;
            } else {
                delete myCheckValues[key];
                checkedCount--;
            }
        });

..... On submit

if(checkedCount > 0) {
            for(var ArrVal in myCheckValues) {
                var values = myCheckValues[ArrVal];   // manipulate with checked rows values data        
            }
        }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.