get Checked row and pass id
get Checked row and pass id
TonicServer
Posts: 8Questions: 2Answers: 0
Hello i use dataTable in my site ... when i have more than 1 page , form just pass active page check row.
i use this jquery for get check row id and pass with form
$("#BtnClick").click(function () {
$.each(
$("input[type=checkbox]"),
function() {
var catName = $(this).attr('name');
datasets[catName] = {
label: catName,
data: []
};
});
$.each(
$("input[type=checkbox]:checked"),
function () {
var catName = $(this).attr('name');
datasets[catName].data.push($(this).val());
});
var data ={};
$.each(
datasets,
function (item, dt) {
var name = item;
var value = dt['data'].join(",");
data[name] = value;
}
);
$("#hiddenForm").autofill(data);
$("#hiddenForm").submit();
});
and this is my hidden form
<button id="BtnClick" class="btn btn-sm btn-success" type="submit">
submit
</button>
@using (@Html.BeginForm("LineRegimeSave", "DietTherapy", FormMethod.Post, new { id = "hiddenForm" }))
{
<input type="hidden" name="BreakFast" value="" />
<input type="hidden" name="Snake1" value="" />
<input type="hidden" name="Lunch" value="" />
<input type="hidden" name="Snake2" value="" />
<input type="hidden" name="Snake3" value="" />
<input type="hidden" name="Dinner" value="" />
<input type="hidden" name="Snake4" value="" />
<input type="hidden" name="AdviseText" value="@TempData["Advise"].ToString()" />
<input type="hidden" name="docFooterId" value="@TempData["footerId"].ToString()" />
}
may you help me how can i get all page checked row ?
This discussion has been closed.
Answers
i read some code in manual but i can not found any thing about multiple selected row with checkbox ...
Hi @TonicServer ,
Have you looked at the Select extension extension, this will probably do what you're after,
Cheers,
Colin
My you help me more ? i can not understand what should i do !
I need to select each rows i want with checkbox (1 or more).
Checkout these Select extension examples:
https://datatables.net/extensions/select/examples/initialisation/checkbox.html
https://datatables.net/extensions/select/examples/api/get.html
Does that help get you started?
Kevin
@kthorngren thank you ... i am newb in jquery ... that example just select one row!
i need to select multiple rows . may help more ?
You can use the
select.style
to configure how you want to select the rows. Here is an example for multi row selection:https://datatables.net/extensions/select/examples/initialisation/multi.html
Kevin
this is exactly what i need : https://www.gyrocode.com/projects/jquery-datatables-checkboxes/
thank you for help @kthorngren