Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
13279 มุมมอง

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 ;)

ผู้เขียน คำตอบที่ดีที่สุด

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 :))

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ม.ค. 19
8322
0
ธ.ค. 24
926
0
ธ.ค. 24
790
2
ก.ค. 24
2471
2
มี.ค. 22
11609