frequent / tableview

jQuery Mobile tableview - responsive table wrapper for JQM tables
29 stars 23 forks source link

Get selected row in tableview #1

Open reto-ineichen opened 12 years ago

reto-ineichen commented 12 years ago

tablewview,js looks very nice, but how can I get the index of the row which was selected with a checkbox?

Is it possible to get the data in this row by cell?

frequent commented 12 years ago

hm... been a while since I did this demo.

In the linked example, where the checkboxes are created automatically, each checkbox has an id like selectRow-1, selectRow-2, ... so you could extract the row number(s) from the checked checkboxes. This would give you the rows.

To get a cell value in a specific row, you could check for the target cells' headers attribute, which is used to toggle columns and contains the id of the column (= in column 1, header cell id = co-1, all cells in this column have headers=co-1)

id=co-0            id=co-1           id=co-2
selectRow-1   headers=co-1      headers=co-2
selectRow-2   headers=co-1      headers=co-2
selectRow-3   headers=co-1      headers=co-2
selectRow-4   headers=co-1      headers=co-2

For example: Say you know the row and need the 5th cell in this row, which contains a value for "price". If this column is named "price" you need to loop through all column header cells and check if the column text() is "price". This will give you the column header cell. Then select the id of this header cell (will be co-5, as it's the 5th column). Then find the cell in your selected row whose headers attribute equals co-5 (header cell id). That should give you the correct cell. Then get it's value via text().

ptrstpp950 commented 12 years ago

Are you planning to upgrade/change this demo? It is really interesting.

frequent commented 12 years ago

you mean update in terms of latest JQM?

ptrstpp950 commented 12 years ago

If it will be possobile :) It is great plugin. I was also thinking about datatables, but this looks much better on my mobile and desktop.

On Mon, Sep 24, 2012 at 2:03 PM, Sven Franck notifications@github.comwrote:

you mean update in terms of latest JQM?

— Reply to this email directly or view it on GitHubhttps://github.com/frequent/tableview/issues/1#issuecomment-8816516.

frequent commented 12 years ago

I happen to have made a tableview-datatables version, too :-)

Give me some time. Need to catch a deadline Thursday, afterwards I should be able to try and commit something here.

ptrstpp950 commented 12 years ago

Great. Thanks a lot.

On Mon, Sep 24, 2012 at 3:00 PM, Sven Franck notifications@github.comwrote:

I happen to have made a tableview-datatables version, too :-)

Give me some time. Need to catch a deadline Thursday, afterwards I should be able to try and commit something here.

— Reply to this email directly or view it on GitHubhttps://github.com/frequent/tableview/issues/1#issuecomment-8817906.

ptrstpp950 commented 12 years ago

Do you have source code of using datatables in JQM?

On Mon, Sep 24, 2012 at 3:12 PM, Piotr Stapp ptrstpp950@gmail.com wrote:

Great. Thanks a lot.

On Mon, Sep 24, 2012 at 3:00 PM, Sven Franck notifications@github.comwrote:

I happen to have made a tableview-datatables version, too :-)

Give me some time. Need to catch a deadline Thursday, afterwards I should be able to try and commit something here.

— Reply to this email directly or view it on GitHubhttps://github.com/frequent/tableview/issues/1#issuecomment-8817906.

frequent commented 12 years ago

You can see my answer on SO here

ptrstpp950 commented 12 years ago

Unfortunattley it works strange during Ajax load in JQM

On Mon, Sep 24, 2012 at 5:23 PM, Sven Franck notifications@github.comwrote:

You can see my answer on SO herehttp://stackoverflow.com/questions/10386821/mobile-data-entry-mobile-friendly-datagrid

— Reply to this email directly or view it on GitHubhttps://github.com/frequent/tableview/issues/1#issuecomment-8822554.

frequent commented 12 years ago

wait for the example. Works fine here, no matter if on first or subsequent pages both with static-updating and ajax-server-side updating.