admin管理员组文章数量:1026989
I just start to learn about bootstrap
and creating a simple project that can show a data into DataTable
but I am having this error Cannot read property aDataSort of undefined
Feel Free to edit my code if i got it wrong
These are my code
JS
var globalPersonId = 1;
var dataTablesOrderedList = "";
$(document).ready(function () {
var dataTablesFirstBS = $('#dataTables-FIrstSample').DataTable({
responsive: true,
processing: true,
info: true,
search: true,
sort: false,
stateSave: true,
order: [[1, "asc"], [2, "asc"]],
lengthMenu: [[50, 100, 200, -1], [50, 100, 200, "All"]],
ajax: { "url": "/BS/GetFirstDataTable" },
columns:
[
{ data: "BSId", title: "", visible: false, searchable: false, sortable: false },
{ data: "Name", title: "Name", sClass: "alignCenter", sortable: false }
]
});
MyFirstBS();
function MyFirstBS() {
dataTablesOrderedList = $('#tblMyFirstBS').DataTable({
responsive: true,
processing: true,
info: true,
retrieve: true,
destroy: true,
search: true,
sort: false,
stateSave: true,
lengthMenu: [[5, 10, 20, -1], [5, 10, 20, "All"]],
ajax: {
"url": "/BS/GetFirstDataTable",
"data": function (d) {
d.BSId = globalPersonId;
}
},
columns:
[
{ data: "BSId", title: "", visible: false, searchable: false, sortable: false },
{ data: "Name", title: "Name", searchable: false, sortable: false }
]
});
}
});
Controller
public JsonResult GetFirstDataTable()
{
var Data = new List<object>();
Data = db.FirstBS.Where(x => x.BSId == x.BSId)
.Select(t =>
new
{
BSId = t.BSId,
Name = t.Name
}).ToList<object>();
return gf.DataTableAjaxHandlerClientSide(Data);
}
I just start to learn about bootstrap
and creating a simple project that can show a data into DataTable
but I am having this error Cannot read property aDataSort of undefined
Feel Free to edit my code if i got it wrong
These are my code
JS
var globalPersonId = 1;
var dataTablesOrderedList = "";
$(document).ready(function () {
var dataTablesFirstBS = $('#dataTables-FIrstSample').DataTable({
responsive: true,
processing: true,
info: true,
search: true,
sort: false,
stateSave: true,
order: [[1, "asc"], [2, "asc"]],
lengthMenu: [[50, 100, 200, -1], [50, 100, 200, "All"]],
ajax: { "url": "/BS/GetFirstDataTable" },
columns:
[
{ data: "BSId", title: "", visible: false, searchable: false, sortable: false },
{ data: "Name", title: "Name", sClass: "alignCenter", sortable: false }
]
});
MyFirstBS();
function MyFirstBS() {
dataTablesOrderedList = $('#tblMyFirstBS').DataTable({
responsive: true,
processing: true,
info: true,
retrieve: true,
destroy: true,
search: true,
sort: false,
stateSave: true,
lengthMenu: [[5, 10, 20, -1], [5, 10, 20, "All"]],
ajax: {
"url": "/BS/GetFirstDataTable",
"data": function (d) {
d.BSId = globalPersonId;
}
},
columns:
[
{ data: "BSId", title: "", visible: false, searchable: false, sortable: false },
{ data: "Name", title: "Name", searchable: false, sortable: false }
]
});
}
});
Controller
public JsonResult GetFirstDataTable()
{
var Data = new List<object>();
Data = db.FirstBS.Where(x => x.BSId == x.BSId)
.Select(t =>
new
{
BSId = t.BSId,
Name = t.Name
}).ToList<object>();
return gf.DataTableAjaxHandlerClientSide(Data);
}
Share
Improve this question
edited Sep 20, 2016 at 9:30
KiRa
asked Sep 20, 2016 at 9:12
KiRaKiRa
9243 gold badges19 silver badges46 bronze badges
7
-
i think you need to set
sortable: false
for all the columns defined under#tblMyFirstBS
DataTable
. Please try that and let me know. – vijayP Commented Sep 20, 2016 at 9:17 -
@vijayP i set it in
dataTablesFirstBS columns
I also set it in my function?. – KiRa Commented Sep 20, 2016 at 9:18 -
i don't see it in
function MyFirstBS()
. Can you please modify your question. – vijayP Commented Sep 20, 2016 at 9:20 - @vijayP sorry typo. Do I need to set in my function? – KiRa Commented Sep 20, 2016 at 9:25
- yes. Also from where you are calling this ` MyFirstBS()`? – vijayP Commented Sep 20, 2016 at 9:27
2 Answers
Reset to default 1i solved that problem in my case by removing the order line
order: [[ 7, "desc" ]],
I solve my problem by removing the second order here is my new order now
order: [[1, "asc"]],
I just start to learn about bootstrap
and creating a simple project that can show a data into DataTable
but I am having this error Cannot read property aDataSort of undefined
Feel Free to edit my code if i got it wrong
These are my code
JS
var globalPersonId = 1;
var dataTablesOrderedList = "";
$(document).ready(function () {
var dataTablesFirstBS = $('#dataTables-FIrstSample').DataTable({
responsive: true,
processing: true,
info: true,
search: true,
sort: false,
stateSave: true,
order: [[1, "asc"], [2, "asc"]],
lengthMenu: [[50, 100, 200, -1], [50, 100, 200, "All"]],
ajax: { "url": "/BS/GetFirstDataTable" },
columns:
[
{ data: "BSId", title: "", visible: false, searchable: false, sortable: false },
{ data: "Name", title: "Name", sClass: "alignCenter", sortable: false }
]
});
MyFirstBS();
function MyFirstBS() {
dataTablesOrderedList = $('#tblMyFirstBS').DataTable({
responsive: true,
processing: true,
info: true,
retrieve: true,
destroy: true,
search: true,
sort: false,
stateSave: true,
lengthMenu: [[5, 10, 20, -1], [5, 10, 20, "All"]],
ajax: {
"url": "/BS/GetFirstDataTable",
"data": function (d) {
d.BSId = globalPersonId;
}
},
columns:
[
{ data: "BSId", title: "", visible: false, searchable: false, sortable: false },
{ data: "Name", title: "Name", searchable: false, sortable: false }
]
});
}
});
Controller
public JsonResult GetFirstDataTable()
{
var Data = new List<object>();
Data = db.FirstBS.Where(x => x.BSId == x.BSId)
.Select(t =>
new
{
BSId = t.BSId,
Name = t.Name
}).ToList<object>();
return gf.DataTableAjaxHandlerClientSide(Data);
}
I just start to learn about bootstrap
and creating a simple project that can show a data into DataTable
but I am having this error Cannot read property aDataSort of undefined
Feel Free to edit my code if i got it wrong
These are my code
JS
var globalPersonId = 1;
var dataTablesOrderedList = "";
$(document).ready(function () {
var dataTablesFirstBS = $('#dataTables-FIrstSample').DataTable({
responsive: true,
processing: true,
info: true,
search: true,
sort: false,
stateSave: true,
order: [[1, "asc"], [2, "asc"]],
lengthMenu: [[50, 100, 200, -1], [50, 100, 200, "All"]],
ajax: { "url": "/BS/GetFirstDataTable" },
columns:
[
{ data: "BSId", title: "", visible: false, searchable: false, sortable: false },
{ data: "Name", title: "Name", sClass: "alignCenter", sortable: false }
]
});
MyFirstBS();
function MyFirstBS() {
dataTablesOrderedList = $('#tblMyFirstBS').DataTable({
responsive: true,
processing: true,
info: true,
retrieve: true,
destroy: true,
search: true,
sort: false,
stateSave: true,
lengthMenu: [[5, 10, 20, -1], [5, 10, 20, "All"]],
ajax: {
"url": "/BS/GetFirstDataTable",
"data": function (d) {
d.BSId = globalPersonId;
}
},
columns:
[
{ data: "BSId", title: "", visible: false, searchable: false, sortable: false },
{ data: "Name", title: "Name", searchable: false, sortable: false }
]
});
}
});
Controller
public JsonResult GetFirstDataTable()
{
var Data = new List<object>();
Data = db.FirstBS.Where(x => x.BSId == x.BSId)
.Select(t =>
new
{
BSId = t.BSId,
Name = t.Name
}).ToList<object>();
return gf.DataTableAjaxHandlerClientSide(Data);
}
Share
Improve this question
edited Sep 20, 2016 at 9:30
KiRa
asked Sep 20, 2016 at 9:12
KiRaKiRa
9243 gold badges19 silver badges46 bronze badges
7
-
i think you need to set
sortable: false
for all the columns defined under#tblMyFirstBS
DataTable
. Please try that and let me know. – vijayP Commented Sep 20, 2016 at 9:17 -
@vijayP i set it in
dataTablesFirstBS columns
I also set it in my function?. – KiRa Commented Sep 20, 2016 at 9:18 -
i don't see it in
function MyFirstBS()
. Can you please modify your question. – vijayP Commented Sep 20, 2016 at 9:20 - @vijayP sorry typo. Do I need to set in my function? – KiRa Commented Sep 20, 2016 at 9:25
- yes. Also from where you are calling this ` MyFirstBS()`? – vijayP Commented Sep 20, 2016 at 9:27
2 Answers
Reset to default 1i solved that problem in my case by removing the order line
order: [[ 7, "desc" ]],
I solve my problem by removing the second order here is my new order now
order: [[1, "asc"]],
本文标签: javascriptCannot read property aDataSortDataTable bootstrapStack Overflow
版权声明:本文标题:javascript - Cannot read property aDataSort . DataTable bootstrap - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745505844a2153600.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论