Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add an ID to the "tr" ? #119

Closed
zagloo opened this issue Sep 25, 2014 · 31 comments
Closed

How to add an ID to the "tr" ? #119

zagloo opened this issue Sep 25, 2014 · 31 comments

Comments

@zagloo
Copy link

zagloo commented Sep 25, 2014

Hello,

How can I do that please ?
In Symfony Twig I tried that :

{% for tuto in categorie.tutoriels %}
    <tr class="{{ (tuto.ID) }}">
        <td>Bob</td>
    </tr>
{% endfor %}

But the class not appear in my html... why ?

@wenzhixin
Copy link
Owner

Sorry, I do not quite understand what use add ID to the tr class.

@pipiscrew
Copy link

the ID supposed is hidden and not appear as column.

generally when using 'bootstrap-table' what is the best method, to get/set the recordID from/to row?

thanks

@pipiscrew
Copy link

hmmm, is cute wenzhixin :)

#HTML - on table ID column#

                    <th data-field="cust_id" data-visible="false">
                        Item ID
                    </th>

#After table initialization#

$('#customers_tbl').on('click-row.bs.table', function (e, row, $element) {
              //here the hidden column is readable :)
              console.log(row.cust_id);
});

[edit]
hmm, another nice way is to use at table properties :

data-click-to-select="true" data-single-select="true"

but is anyway to hide the checkbox column? when I set the data-visible=false to checkbox column weird things happened!

@wenzhixin
Copy link
Owner

I think it is no need to set a ID to the tr element, because you can get the id by row data.

@wenzhixin wenzhixin reopened this Sep 27, 2014
@wenzhixin
Copy link
Owner

#99

@zagloo
Copy link
Author

zagloo commented Oct 6, 2014

Hello !

In fact, I'm using personnal ID ... It's for that I need to set a personnal ID for each "tr" ...
No method for that ?

@zagloo
Copy link
Author

zagloo commented Oct 7, 2014

There is no possibility to add a class or ID in each tr ot td ?

@wenzhixin
Copy link
Owner

You can use rowStyle or cellStyle to set a class in tr or td.

Docs: http://wenzhixin.net.cn/p/bootstrap-table/docs/documentation.html

@zagloo
Copy link
Author

zagloo commented Oct 8, 2014

I'm sorry ... i'm a novice in code... xD

How to use cellStyle with atribute data-cell-style directly in HTLM <table> ?

For example, I have this table

<table id="tab">
            <thead>
            <tr>
                <th>ID</th>
                <th> Name </th>               
            </tr>
            </thead>
            <tbody>
                <tr>
                    <td></td>
                    <td></td>
                </tr>       
            </tbody>
        </table>

I want to had class = personal_ID in my tr like this :

<table id="tab">
        <thead>
            <tr>
                <th>ID</th>
                <th> Name </th>               
            </tr>
        </thead>
         <tbody>
                <tr class="personal_ID1>
                    <td>1</td>
                    <td>BBB</td>
                </tr>     
               <tr class="personal_ID2>
                    <td>2</td>
                    <td>BBB</td>
                </tr>      
         </tbody>
</table>

Thank you and sorry for my stupid question ... :(

@wenzhixin
Copy link
Owner

data-row-style="rowStyle"

function rowStyle(row, index) {
    return {
        classes: 'personal_ID' + row.ID
    };
}

@zagloo
Copy link
Author

zagloo commented Oct 9, 2014

No way to do that only with attribute in html ? because my problem is that I autocomplete my table with Symfony Twig with an array... like that :

 <tbody>
            {% for tuto in categorie.tutoriels %}
                <tr class=' {{ (tuto.ID) }} '>
                    <td></td>
                    <td>{{ (tuto.title) }}</td>
                    <td>{{ (tuto.Date|date("Y/m/d H:i:s")) }}</td>
                    <td>{{ (tuto.NumberClient) }}</td>
                    <td>{{ (tuto.MaxTime) }}</td>                 
                </tr>
            {% endfor %}
</tbody>

Is that why I can't use Javascript to do that... I directly complete Table with Twig... :(

@zagloo
Copy link
Author

zagloo commented Oct 16, 2014

I love very much your plugin ! But it miss that... could add some ID or CLASS directly with attribute in HTML... not just with JAVASCRIPT because in my case it's not adapted ... and finaly I can't add ID or classes ...

@wenzhixin
Copy link
Owner

Hi, I am glad that you like this plugin. If I have time I will consider to support this feature (without writing any JavaScript code, and without using json url) next version. You can star or watch this repo to follow the updates.

Reference to issue #123.

@zagloo
Copy link
Author

zagloo commented Oct 16, 2014

Great ! good job :)

@zagloo
Copy link
Author

zagloo commented Oct 20, 2014

Hi !

Just for know... In how many time you think you can do this ?

@wenzhixin
Copy link
Owner

Saved all id and class of tr and td for html table: http://wenzhixin.net.cn/p/bootstrap-table/docs/examples.html#transform-table.

@zagloo
Copy link
Author

zagloo commented Oct 29, 2014

You are a Dude ! Now your API is almost perect ;o)

thanks a lot :)

@wenzhixin
Copy link
Owner

^_^

@zagloo
Copy link
Author

zagloo commented Nov 6, 2014

Hello,

after some tests, I can't use this... I have always the automatics " data-index " ... and when I put some ID or class directly in HTML, they don't appear :( ... why ?

thanks

@wenzhixin
Copy link
Owner

@zagloo
Copy link
Author

zagloo commented Nov 10, 2014

Yes I saw that but It strange... doesn't work for me ...

@wenzhixin
Copy link
Owner

Can you provide jsFiddle code?

@zagloo
Copy link
Author

zagloo commented Nov 10, 2014

Here it is :
http://jsfiddle.net/hfx9ycqL/3/

:o)

@wenzhixin
Copy link
Owner

I think you need to update the code from src/bootstrap-table.js

@zagloo
Copy link
Author

zagloo commented Nov 10, 2014

I have this :

/**
 * @author zhixin wen <wenzhixin2010@gmail.com>
 * version: 1.3.0
 * https://github.com/wenzhixin/bootstrap-table/
 */

@wenzhixin
Copy link
Owner

@zagloo
Copy link
Author

zagloo commented Nov 10, 2014

humm ... ok lol ... I look better in my side !!

thanks for your help !

@zagloo
Copy link
Author

zagloo commented Nov 10, 2014

It's OK now :)

I don't know why but the code wasn't updated ... I'm using BowerComponnent from Synfony2... and it did'nt work ...

@Sopamo
Copy link
Contributor

Sopamo commented Nov 21, 2014

Would be perfect to also keep all data-* attributes. I think you should be using instead of but that is not possible at the moment.

@gudbergsen
Copy link

How to set this ID from a URL source?

Agree with Sopamo - keep all data-* attributes will be good - and set them all from JSON

@wenzhixin
Copy link
Owner

OK, I will consider that feature. Added as a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants