Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

How to add class in table if checkbox is checked

By
Charlie
on 8/24/14, 8:19 AM 2,129 views

I want to add a class in a table if the checkbox is checked:

Actualy :

<div class="oe_list oe_view"><table class="oe_list_content">    
    <thead>       
      </thead>

     <tbody>
        <tr data-id="196" style="">           
                <th class="oe_list_record_selector" width="1">                
                        <input name="radiogroup" type="checkbox">
                </th>        
                <td data-field="ref" class="oe_list_field_cell oe_list_field_char   oe_readonly ">C140167</td>        
                 <td data-field="display_name" class="oe_list_field_cell oe_list_field_char   oe_readonly ">My data</td>

 

And I Want:

<div class="oe_list oe_view"><table class="oe_list_content">    
    <thead>       
      </thead>

     <tbody>
        <tr data-id="196" class="trselected" style="">           
                <th class="oe_list_record_selector" width="1">                
                        <input name="radiogroup" type="checkbox">
                </th>        
                <td data-field="ref" class="oe_list_field_cell oe_list_field_char   oe_readonly ">C140167</td>        
                 <td data-field="display_name" class="oe_list_field_cell oe_list_field_char   oe_readonly ">My data</td>

 

I tried this code in my .js file:

$(document).ready(function() {
      $(":checkbox").change(function () {
    $(this).parent().parent().toggleClass('trselected');
         });
});

 

but it did not work.

How can I add a class to the parent tr if the input checkbox is checked?

I'm working on something similar (hiding particular columns on demand) if I have success I'll let you in on it ;)

Michael Watchorn
on 11/9/15, 6:43 PM
0
Charlie
On 8/24/14, 2:27 PM

I Tried this code in my js file, don't work... :/

openerp.my_module = function(instance){

instance.web.ListView.List = instance.web.Class.extend({

        .selbox('th.oe_list_record_selector', 'click', function (e) {
                e.stopPropagation();
                var selection = self.get_selection();
              
                $(this).parent().addClass("trselected");
                
            })
        });

}

I don't understand ... It's completely crazy not to add a single fonction... I know, I understand nothing that language JAVASCRIPT! I'm not alone I think :))

Charlie
on 9/4/14, 4:40 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 8/24/14, 8:19 AM
Seen: 2129 times
Last updated: 11/9/15, 6:43 PM