Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all 81384 articles
Browse latest View live

Exporting tables with complex header

$
0
0

Still not resolved? if anything is there please share with me.


DateTime Picker selecting February date returns March date

$
0
0

When selecting a February 2017 date, it instead returns a March date.

Steps to reproduce:
1. Go to date example page.
2. Click "New" button.
3. Select a February 2017 date.

Styling specific columns in pdfHtml5

$
0
0

With doc.defaultStyle.noWrap = true; I can noWrap the whole table when exporting to pdf. But how can I apply noWrap only to a certain column? So e.g. only to column 5 and 7 ?

{
    extend:    'pdfHtml5',
    text:      'PDF',
        exportOptions: {
            columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
        },
    customize: function(doc) {

        doc.defaultStyle.noWrap = true;

    }
}

Many thanks

Export Excel treats the string as a number

$
0
0

Hi,
I tried to search but with no luck (the question is already asked but the solutions don't work): i'm using ExcelHtml5 to export data from table to xlsx, i have a column with 5 numbers and the first could be zeros. When i export as xlsx i get them truncated (137 where 00137).

I tried to remove the if: "typeof row[i] === 'number' .... " from buttons.html5.js with no luck.
Then i inserted this in the column definition:

{ "name": 'Cap', render: function (data, type, row) {
       return type === 'export' ? '="'+data+'"' : data;
} }

but with Excel 2016 i see: ="00137" in the field.

There are any solutions to show numbers as strings in the xlsx file?

Trying to create a yadcf filter for a column with images

$
0
0

I need to create a filter on a tipical columns created with images: each field is an image with this format:

<img src='http://lab.onclud.com/psm/blackcircle.png' class='notasg'>

I've created a fiddle example here.

An explication:
* there are only 2 diferents status: [assigned/not assigned] although there are 4 diferents images (black, red, yellow and green).
* Only black image correspond to not assigned status. The others three ones (red, yellow and green) correspond to assigned status.
* As you could see, I've tried to differentiate those status by class HTML tag in img elements (notasg/asgn).

Thanks in advance.

Table Borders export excel

Refresh ajax grid not working

$
0
0

I have a page that I'm working on using asp.net mvc core. The page includes a datatables grid populated with an ajax source. This is working as expected. I click a button to bring up a semantic ui modal to add a new entry. This is also working as expected and the new item is added to the database.

On the success handler for the form post I want to refresh the grid. The success handler is being hit as I have verified that with an alert box. Here is the ajax call.

<script type="text/javascript">
function submitForm() {
    $.ajax({
        url: "/Division/CreateTableGroup",
        type: "POST",
        data: $("form").serialize(),
        success: function(data){
            $("#table_group_list").DataTable().ajax.reload();
        },
        error: function (response) {
            alert("error")
        }
    });
}
</script>

Any idea why the reload might not be happening?

Is it possible to define specific width for each columns in datatable?

$
0
0

Hi Guys,

First of all I am newbie for this datatable. I am using .Net/c# with MVC 1 and Datatable legacy for my project. I have added datatable but I am having some issues. I am unable to define specific width for each columns. Below is my code, what am I missing here.

var branchId = '<%=ViewData["branchId"]%>';
$.ajax({
    url: '/Home.mvc/Home/GetDataDT',
    method: 'post',
    dataType: 'json',
    data: {
        branchId: branchId
    },
    success: function (data) {
        data.forEach(function (row) {
            row.push('<a id="iconEdit' + row[0] + '" name="EditData" href="<%=this.Url.Action("GetDataByID","Admin") %>?branchId=<%= Convert.ToInt32(this.ViewData["branchId"]) %>&Id=' + row[0] + '" title="Edit Data" class="actionButton" height="300px" width="610px"><span>Edit</span></a>')
        });

        $('#DataOp').dataTable({
            "bPaginate": true,
            "sPaginationType": "full_numbers",
            "bSearchable": true,
            "bAutoWidth": false,
            "iDisplayLength": 10,
            "bJQueryUI": true,
            "aaData": data,
            "aoColumns": [
                    { mData: 'Id', "bVisible": false, "bSearchable": false },
                    { mData: 'Name', "sWidth": "68px fixed" },
                    { mData: 'Details', "sWidth": "125px fixed" },
                    { mData: 'Functions', "sWidth": "20px fixed" }
            ]
        });
    }
});

will sWidth be used in aoColumns. If not how can I mention it.


hyperlink to website stored in 1 column

$
0
0

i have made a table of 10 columns in which 1 column displays website addresses. What i need is that when one clicks on those websites, it should be redirected to that website.Can you please help me on this

Is it possible to enter a php function instead of a table field?

$
0
0

Maybe is a silly question but I could not find an example.
In a table I need to add a column that is resulted from an sql query, a simple count. I solved this by calling a php from javascript on render. Of course, this created the problem with multiple request on server due to the way Datatables is build. I solved this by caching the requests in a local array so this reduced the number of ajax calls to the number of rows but is there a better way then this work-around?
Can I return the result of the query directly from server-side php that initiate the DataTable and the Editor?

R shiny buttons export formated columns

$
0
0

The extensions 'Buttons' works great for shiny application. However it export the data without formatting. Is there a way to export data with format (e.g. percentage, or currency)?

Reproducible code

library(DT)

data.frame(a = c(1,2),
b = c(2,3)) %>%
datatable(extensions = 'Buttons', options = list(
dom = 'Bfrtip',
buttons = c('copy', 'csv', 'excel', 'pdf', 'print')) )%>%
formatPercentage('a') %>%
formatCurrency('b')

Change number of decimals to show

$
0
0

Could be the number of decimal places changed by an input value dynamically?
How can i do this?

Multi-row editing

$
0
0

Hello,

Is it possible to choose which fields will be displayed to editing in Multi-row editing modal?

Like:

 buttons: [
            {
                extend: 'edit',
                text: 'Edit',
                className: 'btn btn-primary',
                editor: editor.fields('quantity','cost')
            }

Issue while loading the data table

$
0
0

Hi,

Am new to .Net web application, datatables and editor. I went through the basic examples in the website. I am facing an issue. Hope someone can throw some light on this.

Please find below the code that i use and error message i get.

HTML:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="xxx.cs" Inherits="xxx" %>

<!DOCTYPE html>

<html>
<head runat="server">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- end required meta tags -->

<title>test</title>



<link href="../DataTables/Bootstrap-3.3.7/css/bootstrap.css" rel="stylesheet" type="text/css" /><!-- Do not edit -->
<link href="../DataTables/Bootstrap-3.3.7/css/bootstrap-theme.css" rel="stylesheet" type="text/css" /><!-- Define theme changes here. -->
<link href="../DataTables/DataTables-1.10.13/css/dataTables.bootstrap.css" rel="stylesheet" type="text/css" />
<link href="../DataTables/Buttons-1.2.4/css/buttons.bootstrap.css" rel="stylesheet" type="text/css" />
<link href="../DataTables/Select-1.2.0/css/select.bootstrap.css" rel="stylesheet" type="text/css" />
<link href="../DataTables/Editor-1.6.1/css/editor.bootstrap.css" rel="stylesheet" type="text/css" />
<link href="../Styles/test.css" rel="stylesheet" type="text/css" />



<script src="../DataTables/datatables.min.js" type="text/javascript"></script>
<script src="../Scripts/test.js" type="text/javascript"></script>
<!-- End JavaScript Includes -->

</head>
<body>

test

col1 col2 col3 col4 col5

</body>

</html>

Javascript:

(function () {

var editor;


$(document).ready(function () {


    editor = new $.fn.dataTable.Editor({
        ajax: {
        url: "URL to DB service",
        contentType: "application/json; charset=utf-8",
        dataType: "json" },
        table: "#Grid-01",
        fields: [

        {
        "label": "col 1",
        "name": "col1"
    },
        {
            "label": "col 2",
            "name": "col2"
        },
        {
            "label": "col 3",
            "name": "col3"
        },
        {
            "label": "col 4",
            "name": "col4"
        },
        {
            "label": "col 5",
            "name": "col5"
        }

    ],
    formOptions: {
        inline: {
            onBlur: 'submit'             }
    }
});

var table = $('#Grid-01').DataTable({
    lengthChange: false,
    order: [],
    ajax: {
        url: "URL to DB service",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        type: "GET",
        dataSrc: "d"
    },
    columns: [

                    { "data": "col1" },
                    { "data": " col2" },
                    { "data": " col3" },
                    { "data": " col4" },
                    { "data": " col5" }
        ]
        });

// Display the buttons
new $.fn.dataTable.Buttons(table, [
        { extend: "create", editor: editor },
        { extend: "edit", editor: editor },
        { extend: "remove", editor: editor }
    ]);

//Add the buttons to the appropriate Bootstrap class
table.buttons().container()
        .appendTo($('.col-sm-6:eq(0)', table.table().container()));



$('#Grid-01').on('click', 'tbody td:not(:first-child)', function (e) {
    editor.inline(this);
});

});

} ());

Output of DB service:

{"d":"[{\"col1\":\"12345\",\"col2\":\"123\",\"col3\":\"123\",\"col4\":\"100\",\"col5\":\"test_1]"}

Error message :

Datables warning: table id = Grid-01 – Requested unknown parameter ‘col1’ for row 0, column 0.

Thanks!

How to use JSON object with unique keys instead of JSON array of objects as data source?

$
0
0

I have JSON formatted similar to the JSON below.

{
   "Tiger Nixon": {
      "Position": "System Architect",
      "Office": "Edinburgh",
      "Age": 61,
      "Start date": "2011/04/25",
      "Salary": "$3,120"
   },
   "Garrett Winters": {
      "Position": "Director",
      "Office": "Edinburgh",
      "Age": 63,
      "Start date": "2011/07/25",
      "Salary": "$5,300"
   }.
}

I want to make the key containing the name (ex. "Tiger Nixon" and "Garrett Winters" as column 1, then from there on use the values associated with that key as the values for the rest of the columns in that row.

I have played around with the column option but I can't think of how this would be possible.

Is the only way to do this to loop through my object and set it to an array?


search() for all matches to either one of two values?

$
0
0

Is there a way to use search() to return all matches for either of two (or more) values?

Example: Return all rows matching either "knowledge" or "processes"?

All-in-one datatables js/css not working?

$
0
0

Updated to a recent copy of Datatables and Editor, used the new download feature to get a bundle of everything I use. The first issue I've run into is using the 'Buttons' Extension. Even though it is included in the 'min':

/*!
Buttons for DataTables 1.2.4
©2016 SpryMedia Ltd - datatables.net/license
*/

Any call to Buttons in dom throws, "Unable to get property 'buttons' of undefined or null reference", like the all-in-one datatables.min.js doesn't actually include the downloaded/referenced extension.

I'm going to go through the release notes again in case there is an upgrade path/configuration change I missed.

Creating a tabbed page with 5 reports

$
0
0

I have been mucking with this for a week, and it is not clean at all.
My goal is to pull similar data from 5 separate dimension tables, mapped to a single fact table.
My current issue is the ability to get the tables to seemlessly load data.
Each attempt has a variety of popups and the initial load is broken.
Hoping someone can review and help me to correct.

http://live.datatables.net/canezame/2/edit?html,css,js,console

Thank you,
Allan

Paged table and additional getJSON calls on visible rows only

$
0
0

We have data that is stored in Access databases (not my choice but we need to deal with it) and I need to display information which is pulled from a number of different tables across different databases. We've been using a homebrew system for a while which has limited functionality and DataTables seems to be the perfect solution but I can't quite get the functionality I'm looking for.

The user enters a query in a form field and the results are populated in numerous DataTables objects and made visible to the user. The results for a query can be as little as 1 or in the 100's. After the initial query returns and DataTables has been filled and displayed to the user, some DataTables require additional getJSON calls to query another database which updates a couple cells for each row. The cells are initially filled with loader icons until the getJSON returns and the cells are populated with the result.

DataTables is initialized to "page" the results and allows the user to filter the results as well. I used the createdRow callback but it doesn't appear to be what I want as it will execute for all rows, not just those displayed. If the initial results are in the 100's, I don't want to be making 100's of getJSON calls, I only want calls for the data currently displayed.

So how do I only update the cells that are visible for paged results? Are there specific callbacks to be used, or how do I get a list of visible rows regardless if a page change occurred or the results have been filtered?

View after DataTables has loaded the initial results and performing addition getJSON calls to fill the "Warranty" column for each row

View after DataTables has finished getJSON calls for each row

postgresql: fully qualified table names are causing me heartache.

$
0
0

Hi All:

I have been working to build a data table that exposes my parent table which is ENTITY in postgresql.
Beyond that, I am using PHP / Mjoin in order to create a relationship with a child table which is called TOUCHES.

The snippet pasted in below does what I want.

HOWEVER: I seek a better way, a way that allows me to use the fully qualified table/column names, which are:

contactschema.entity.entity_key
contactschema.touches.parent_entity_key

At issue is the apparent limitation that Mjoin (link) does not like my fully qualified names, having as they do, two dots each.

To this point I have found only an ugly workaround: I had to alter my user in the database such that he has a hard coded search_path. (this is akin to declaring a default schema name).

Does anyone know of a better syntax or a better solution?

->join(
Mjoin::inst( 'touches' )
->link( 'entity.entity_key', 'touches.parent_entity_key' )
->fields(
Field::inst( 'parent_entity_key' )
)
)
->process( $_POST )
->json();

Viewing all 81384 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>