tableview icon indicating copy to clipboard operation
tableview copied to clipboard

Get selected row in tableview

Open reto-ineichen opened this issue 12 years ago • 10 comments

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?

reto-ineichen avatar Sep 23 '12 06:09 reto-ineichen

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().

frequent avatar Sep 23 '12 10:09 frequent

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

ptrstpp950 avatar Sep 24 '12 11:09 ptrstpp950

you mean update in terms of latest JQM?

frequent avatar Sep 24 '12 12:09 frequent

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 [email protected]:

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.

ptrstpp950 avatar Sep 24 '12 12:09 ptrstpp950

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.

frequent avatar Sep 24 '12 13:09 frequent

Great. Thanks a lot.

On Mon, Sep 24, 2012 at 3:00 PM, Sven Franck [email protected]:

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 avatar Sep 24 '12 13:09 ptrstpp950

Do you have source code of using datatables in JQM?

On Mon, Sep 24, 2012 at 3:12 PM, Piotr Stapp [email protected] wrote:

Great. Thanks a lot.

On Mon, Sep 24, 2012 at 3:00 PM, Sven Franck [email protected]:

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 avatar Sep 24 '12 15:09 ptrstpp950

You can see my answer on SO here

frequent avatar Sep 24 '12 15:09 frequent

Unfortunattley it works strange during Ajax load in JQM

On Mon, Sep 24, 2012 at 5:23 PM, Sven Franck [email protected]:

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.

ptrstpp950 avatar Sep 24 '12 19:09 ptrstpp950

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

frequent avatar Sep 24 '12 22:09 frequent