How to get data from column on a row click..
How to get data from column on a row click..
I am setting up (trying to) a edit/delete link in my table.
Can be seen here http://www(@)fisheragservice(@)com/tm/users(@)html Please replace the (@)'s with .'s (don't want spam bots indexing the page).
When I click the delete image on the right, I want to get the value from the ID column so I can pass it to a server side script to delete the mysql entry.
I'm capturing the click with this:
[code]
$('#datatable tbody tr a.delete img').live( 'click', function (e) {
var rowID = $('a').attr('href');
alert(rowID);
if (!fancyConfirm(rowID, "Are you sure you want to delete this record?", function(ret) { alert(rowID) }))
e.preventDefault();
});
[/code]
I tried storing the ID I needed in the href tag but not sure how to extract it.. Anyone have an idea of the best way to do this?
Can be seen here http://www(@)fisheragservice(@)com/tm/users(@)html Please replace the (@)'s with .'s (don't want spam bots indexing the page).
When I click the delete image on the right, I want to get the value from the ID column so I can pass it to a server side script to delete the mysql entry.
I'm capturing the click with this:
[code]
$('#datatable tbody tr a.delete img').live( 'click', function (e) {
var rowID = $('a').attr('href');
alert(rowID);
if (!fancyConfirm(rowID, "Are you sure you want to delete this record?", function(ret) { alert(rowID) }))
e.preventDefault();
});
[/code]
I tried storing the ID I needed in the href tag but not sure how to extract it.. Anyone have an idea of the best way to do this?
This discussion has been closed.
Replies
[code]
$('#datatable tbody tr a.delete').live( 'click', function (e) { var rowID = $(this).attr('href');
alert(rowID);
if (!fancyConfirm(rowID, "Are you sure you want to delete this record?", function(ret) { alert(rowID) }))
e.preventDefault();
});
[/code]
I like the website and design!!! It's really great template [fisheragservice...]
I'm having same problem as you but im not good with: javascript and ajax
Please can you help me :( it's been two days that im stuck with this problem.
Here is my code:
[code]
$(document).ready(function() {
$('#table-depenses').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "./_server_processing_depenses.php"
} );
} );
[/code]
Data are loaded via this file: ./_server_processing_depenses.php
this is my table:
[code]
id
Date
Categorie
S.Categorie
Details
Voiture
D.Caisse
D.H.Caisse
Banque
N.Ch
[code]
$(document).ready(function() {
$('#table-depenses').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "./_server_processing_depenses.php"
"aoColumns": [
{"bSortable": false, "bSearchable": false,
"fnRender": function(oObj) {
var csId = oObj.aData[1];
return 'Edit';
}},
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null
]
});
});
[/code]
This problem really makes me sick :s
I used the plugin tablesorter before and now I changed all my tables to work with DataTables.
I had a porblem with tables which have large number of data, tablesorter+its plugin pager doesn't have limit and offset when using SELECT query. That's why loading all data may not work. And they told me on forums that it's not easy to add this to the script...
Now i'm using DataTables and i've never used JSON in addition i'm not really good with javascript and ajax.
A long story :p
Thanks again, i'll try to make it work =)
here is a screenshot of my table :)
http://data.imagup.com/5/1108911449.png
Thank you ^^
[code]http://themeforest.net/item/terminator-13-different-admin-backend-pages/117412[/code]
Its only $20 but well worth the price and supports DataTables.. I tried a few others but had too many problems with cross-browser support...
Yeah it worth the price, it's just $20
Thanks again, you were very helpful :)
sorry to disturb you, but can you help me out? im having the same problem as you did, i tried your solution but i dont think i understood it.
In one of the columns of my table i put this
[X]
so i could capture the click and get one of the row cell value and send it to a server side script to delete the entry from a sqlite file.
i search everywhere here and found out that i probably need to use the fngetdata/fngetposition/fngetnodes functions, but i didnt see you using it, how did you got the rowID so you could delete this row?
thanks!
I've found an easy method :)
@Darko
You need to add a column to your table:
http://fbta.tumblr.com/post/1374357393/adding-extra-columns-in-jquery-datatable
Then you can put the link on the element inside your delete as usual
After reading the Tuto, here is a code that works:
http://rapidshare.com/files/441068884/datatables_server_processing_add_extra_column.zip
Maybe you, also, need to read this:
http://datatables.net/forums/comments.php?DiscussionID=1581
Good luck
i wish i could use your solution but json doesnt seem to work with sqlite.
thanks!
[/code]
Thanks Keyser,
Finally got it working but where do I add target="_blank" in the above code if i want it to open to a new page?
Thanks for sharing your solution. It helped me out of a jam!