jquery-datatables

How to manually update datatables table with new JSON data

。_饼干妹妹 提交于 2019-12-17 03:32:26
问题 I am using plugin jQuery datatables and load my data which I have loaded in DOM at the bottom of page and initiates plugin in this way: var myData = [ { "id": 1, "first_name": "John", "last_name": "Doe" } ]; $('#table').dataTable({ data: myData columns: [ { data: 'id' }, { data: 'first_name' }, { data: 'last_name' } ] }); Now. after performing some action I want to get new data using ajax (but not ajax option build in datatables - don't get me wrong!) and update the table with these data. How

How to manually update datatables table with new JSON data

我的梦境 提交于 2019-12-17 03:32:17
问题 I am using plugin jQuery datatables and load my data which I have loaded in DOM at the bottom of page and initiates plugin in this way: var myData = [ { "id": 1, "first_name": "John", "last_name": "Doe" } ]; $('#table').dataTable({ data: myData columns: [ { data: 'id' }, { data: 'first_name' }, { data: 'last_name' } ] }); Now. after performing some action I want to get new data using ajax (but not ajax option build in datatables - don't get me wrong!) and update the table with these data. How

Populate Datatable with Ajax call

匆匆过客 提交于 2019-12-14 03:44:09
问题 I want to display the values into the table using an AJAX call. The code used for it is, initTable(); function initTable (){ return $('#exEmpListTable').dataTable({ "bPaginate": false, "sScrollY": "200px", "bScrollCollapse": true }); } function tableActions (){ var oTable = initTable(); // perform API operations with oTable oTable.fnSort( [ [1,'desc']] ); } $("#btnShowExEmpList").click(function (e){ var selectedShop = $('#Shop').val(); if(selectedShop == null){ alert(" Please select a shop

datatables and server-side processing - load on demand

懵懂的女人 提交于 2019-12-13 14:19:58
问题 I've build simple table using DataTables and I successfully connected server-side script to populate my table with data. Above my table I have 2 checkboxes and 2 date selects to specify filter criterias. When my page is loading I get table filled, because at startup datatable is pulling first page of data from server. I would like to disable first initial data load, so when page is loaded I'll get empty table, then after I'll select criterias and press 'Load' button data will be loaded. I

DataTables save state scroll position

纵然是瞬间 提交于 2019-12-13 06:16:10
问题 I've been looking around on the net for hours about this save scroll position for DataTables, but without any luck. At least not for my case. According to datatables, to save the state of the scrollbar I need this line of code: $(document).ready(function() { var oTable = $('#example').dataTable( { "sScrollY": "200px", "sAjaxSource": "media/data/2500.txt", "sDom": "frtiS", "bDeferRender": true, "bStateSave": true } ); } ); But since I'm not having any text file with the data which I can parse

Change date format in js for jquery datatable

瘦欲@ 提交于 2019-12-13 05:11:23
问题 I have this date in table: "2013-10-08T00:00:00" I want to set it in format "dd.MM.yyyy" in datatable source i changed like this: { "bSortable": true, "mData": "PublishDate", "bSearchable": true, "mRender": function (data, type, row) { if (data) { debugger; var re = /-?\d+/; var m = re.exec(data); var d = new Date(parseInt(m[0])); var curr_date = d.getDate(); var curr_month = d.getMonth() + 1; //Months are zero based var curr_year = d.getFullYear(); var formatedDate = curr_date + "/" + curr

jQuery Datatables Column list rendering behind the jQuery Modal Dialog

空扰寡人 提交于 2019-12-13 04:25:14
问题 I have a jQuery modal dialog in which I am rendering a datatable. I am required to use the ColVis plugin in order to dynamically show or hide columns of this datatable. The problem is that when I click on the Show/Hide Columns button, the column list does not render on the modal dialog. It renders behind it! I have to close the dialog in order to see this list. The same thing when implemented in a normal page(without a modal dialog) works absolutely fine. Any idea how to fix this modal dialog

Value is coming back as Undefined

帅比萌擦擦* 提交于 2019-12-13 03:51:13
问题 I am using jquery datatables to display results on a table and then passing ID as URL parameter, we able to display details of a particular record to user. So far, this works fine. However, I have been asked to pass a second url parameter called user and this is presenting problems. When I run the code, it is no longer displaying details page. Upon reviewing the code using firebug, I found an error that says: john is undefined . john.doe is the value being displayed on the url that looks more

Scroll to selected row in DataTables jQuery plugin

て烟熏妆下的殇ゞ 提交于 2019-12-13 03:48:50
问题 I have a dataTable with infinite scrolling. I want to scroll to a selected row on table refresh $('#table1').dataTable({ 'aaData': data, 'aoColumns': columns, 'bInfiniteScroll': true, 'bColumnCollapse': true, 'sScrollY': '200px' }); $('#btnScroll').click(function(){ $('.dataTables_scrollBody').scrollTo($('#table1 tbody tr').eq(3), 800); }); But it does not scroll to the row 回答1: You can use animate to scroll to your position $('.dataTables_scrollBody').animate({ scrollTop: $('#table1 tbody tr

Can I load text / flat json from datatable.net?

十年热恋 提交于 2019-12-13 03:43:37
问题 Hi i have been using datatables but have not tried loading data view pure json object. I always use sAjax source so it always point to a url. My question is how to pass a json object directyl so that it will eliminate the url 回答1: Use Json.parse and add the values in a loop: $(function() { json = '{ "employees" : [' + '{ "firstName":"John" , "lastName":"Doe" },' + '{ "firstName":"Anna" , "lastName":"Smith" },' + '{ "firstName":"Peter" , "lastName":"Jones" } ]}'; parsedJson= JSON.parse(json);