Updates not working on second page
Updates not working on second page
rogersbilly
Posts: 8Questions: 1Answers: 0
I'm using Asp.net MVC to update the assigned user for a list of tasks. The update works fine on the first page no matter how many are displayed on the first page 10,50 or 100.
When we click 'Next' to go to the second page and click to update the tasks, the taskIds do not get posted back to the controller.
Can anyone see what I'm doing wrong in the code below?
[code]
/*global $, jQuery,document,fnCreateSelect*/
$(document).ready(function () {
"use strict";
$('.check:button').toggle(function () {
$('input:checkbox').attr('checked', 'checked');
$(this).val('uncheck all');
}, function () {
$('input:checkbox').removeAttr('checked');
$(this).val('check all');
});
/* Initialise the DataTable */
var oTable = $('#example').dataTable({
"aoColumns": [
{ "sWidth": "10%" },
{ "sWidth": "10%" },
{ "sWidth": "10%" },
{ "sWidth": "10%" },
{ "sWidth": "10%" },
{ "sWidth": "10%" },
{ "sWidth": "10%" },
{ "sWidth": "10%" }
],
"oLanguage": {
"sSearch": "Search all columns:"
},
"bAutoWidth": false
});
/* Add a select menu for each TH element in the table footer */
$("tr td.filter").each(function (i) {
if (i > 0) {
this.innerHTML = fnCreateSelect(oTable.fnGetColumnData(i));
$('select', this).change(function () {
oTable.fnFilter($(this).val(), i);
});
}
});
});
[/code]
Thanks for any help
When we click 'Next' to go to the second page and click to update the tasks, the taskIds do not get posted back to the controller.
Can anyone see what I'm doing wrong in the code below?
[code]
/*global $, jQuery,document,fnCreateSelect*/
$(document).ready(function () {
"use strict";
$('.check:button').toggle(function () {
$('input:checkbox').attr('checked', 'checked');
$(this).val('uncheck all');
}, function () {
$('input:checkbox').removeAttr('checked');
$(this).val('check all');
});
/* Initialise the DataTable */
var oTable = $('#example').dataTable({
"aoColumns": [
{ "sWidth": "10%" },
{ "sWidth": "10%" },
{ "sWidth": "10%" },
{ "sWidth": "10%" },
{ "sWidth": "10%" },
{ "sWidth": "10%" },
{ "sWidth": "10%" },
{ "sWidth": "10%" }
],
"oLanguage": {
"sSearch": "Search all columns:"
},
"bAutoWidth": false
});
/* Add a select menu for each TH element in the table footer */
$("tr td.filter").each(function (i) {
if (i > 0) {
this.innerHTML = fnCreateSelect(oTable.fnGetColumnData(i));
$('select', this).change(function () {
oTable.fnFilter($(this).val(), i);
});
}
});
});
[/code]
Thanks for any help
This discussion has been closed.
Replies
Allan
Your line `$("tr td.filter")` is only getting the nodes on the current page.
Allan
var nNodes = oTable.fnGetNodes( );
nNodes.each(function (i) {
if (i > 0) {
this.innerHTML = fnCreateSelect(oTable.fnGetColumnData(i));
$('select', this).change(function () {
oTable.fnFilter($(this).val(), i);
});
}
});
EDIT: that didn't work, not sure if that's what you meant though
I ended up taking a different approach. Instead of using Asp.net MVC model binding to pass the data back to the controller on the postback I wired up a button to call a jquery script. The jQuery script collects all the selected ids and passes them back to the controller using an ajax call.
Now it works on all pages and when filtering/searching is used.
Good to hear you got a solution in the end :-)
Allan