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

Reload/refresh table after event

$
0
0

I am trying to reload the table but I can't seem to find the way to call the reload function.
In the .done function of the 'revoke' event is where I'm trying to call it $(document).on("click", '.revoke', function (event).
Here is how I'm calling it but fails: $('#example').data.reload(); or table.reload(); or table.ajax.reload();
Any ideas?

<script>
    $(document).ready(function () {
       var thedata = GetPermissions();

        var table = $('#example').DataTable({
            data: jQuery.parseJSON(thedata),
            columns: [
                { data: 'Professional' },
                { data: 'Patient' },
                {
                    data: "View",
                    render: function (data, type, row) {
                        if (data === true) {
                            return '<input type="checkbox" checked disabled>';
                        }
                        return '<input type="checkbox" disabled>';
                    }
                },
                {
                    data: "Edit",
                    render: function (data, type, row) {
                        if (data === true) {
                            return '<input type="checkbox" checked disabled>';
                        }
                        return '<input type="checkbox" disabled>';
                    }
                },
                {
                    data: "Insert",
                    render: function (data, type, row) {
                        if (data === true) {
                            return '<input type="checkbox" checked disabled>';
                        }
                        return '<input type="checkbox" disabled>';
                    }
                },
                {
                    data: "Delete",
                    render: function (data, type, row) {
                        if (data === true) {
                            return '<input type="checkbox" checked disabled>';
                        }
                        return '<input type="checkbox" disabled>';
                    }
                },
                {
                    data: "Revoke",
                    render: function (data, type, row) {                     
                            return '<input type="button" class="btn btn-danger btn-xs revoke" data-pro="' + row.ProfessionalID + '" data-pat="' + row.PatientID + '" name="revoke" value="Revoke">';
                     }
                }
            ]
        });

        $(document).on("click", '.revoke', function (event) {
            var sf = $.ServicesFramework(<%=ModuleId %>);
                var serviceUrl = sf.getServiceRoot('omnibody');
                var revoke = { 'ProfessionalID': $(this).data('pro'), 'PatientID': $(this).data('pat') };

                $.ajax({
                    type: "POST",
                    cache: false,
                    url: serviceUrl + "/ModuleTask/RevokeAccessRights",
                    beforeSend: sf.setModuleHeaders,
                    contentType: "application/json; charset=utf-8",
                    data: JSON.stringify(revoke)
                }).done(function (result) {
//PROBLEM IS HERE
                    // $('#example').data.reload();
                    table.reload();
                }).fail(function (xhr, result, status) {
                    alert('GetPermissions ' + xhr.statusText + ' ' + xhr.responseText + ' ' + xhr.status);
                });
            });
    });
    
    function GetPermissions() {
        var sf = $.ServicesFramework(<%=ModuleId %>);
        var serviceUrl = sf.getServiceRoot('omnibody');
        var jdata;
        $.ajax({
            type: "GET",
            cache: false,
            async: false,
            url: serviceUrl + "/ModuleTask/GetAccessRightsPivoted",
            beforeSend: sf.setModuleHeaders,
            contentType: "application/json; charset=utf-8"
        }).done(function (result) {
            jdata = result;
            return jdata;
        }).fail(function (xhr, result, status) {
            alert('GetPermissions ' + xhr.statusText + ' ' + xhr.responseText + ' ' + xhr.status);
        });
        return jdata;
    }
</script>

Image column

AJAX data security issue

$
0
0

Hi,
I am using datatables ajax method of populating a table. We have now started using an extra layer of protection on our server and I am getting the following log entries coming from the ajax calls.

[id "981173"] [rev "2"] [msg "Restricted SQL Character Anomaly Detection Alert - Total # of special characters exceeded"] [data "Matched Data: ] found within ARGS_NAMES:columns[0][data]: columns[0][data]"]

Looks like it doesnt like the [] brackets. Anyone ever came across anything like this before using datatables and anyone any idea how I could resolve this because removing the rule isn't an option?

Thanks

tr click event

$
0
0

hi

from a tr click envent, is it possible to get the cell we have clicked?

thanks

Uncaught TypeError: extender is not a function

$
0
0

I'm trying to implement DataTable editor in my application and currently facing issue> Uncaught TypeError: extender is not a function whenonBlur: 'submit'is called.
When I tried to debug the lib I found out that there is no function _fnExtend which makes var extender = $[O12][J3p][u12][o3p]; extender undefined.

How to get a list of individual value from a datatable

$
0
0

Hi All:

I have a datable called "creditCardTableId" that have 100 records, column 4 have a balance column where user enter a value for each balance. I needed to get the 100 records for each balance the user enter and see if the value is greater than 100 or less than .10 cents.

I tried to use $('#creditCardTableId') outside of the datatable but not sure how to do it?

This example used a callback:
https://datatables.net/examples/advanced_init/footer_callback.html

But I am not sure how to use the "api.column(4).data()" if I am outside of the database.( javascript code called outside of the datatable definition")

FixedHeader column width not calculating properly with multi column headers

$
0
0

Here is a minimal example, note the addition of a multi column header: http://live.datatables.net/ladekogo/1

If you expand these rows to take up enough space to add a vertical scrollbar to the page, and scroll down, FixedHeader does not calculate the proper column widths and the column headers resize as a result.

How can I fix this?

I am also having a problem where the fixedheader width is incorrect if the datatable initially takes up less than 100% of the width of the page and a scrollbar is then added, but I've solved that for now by calling table.fixedHeader.adjust() on a fast enough timer that it doesn't really matter to the end user. Is there a correct solution?

Thanks!

Upgrading to Editor 1.8.0

$
0
0

I am trying to upgrade from 1.7.4 to 1.8.0 using the PHP version. I am using IIS 10 and MS SQL server. I am removing my current Editor php folder and copying in the new folder copying the files and the newly structured folders as per the instructions. Once completed i am updating the config.php as normal. As far as I understand as per other versions that should be it, however I am receiving a popup message:

"{"error":"An error occurred while connecting to the database 'DB'. The error reported by the server was: SQLSTATE[08001]: [Microsoft][ODBC Driver 17 for SQL Server]SQL Server Network Interfaces: Connection string is not valid [87]. "}"

and a message in the PHP error log

"PHP Fatal error: Uncaught Exception: Unknown database driver type. Must be one of Mysql, Oracle, Postgres, Sqlite, Sqlserver, Db2, Firebird in D :\wwwroot\Web\php\Database.php:56
Stack trace:

__construct(Array)">__construct(Array)">0 D :\wwwroot\Web\php\Bootstrap.php(53): DataTables\Database->__construct(Array)

1 D :\wwwroot\Web\php\DataTables.php(33): require('D :\wwwroot\web...')

2 D :\wwwroot\Web\inc\Report_edit.php(13): include('D :\wwwroot\web...')

3 {main}

thrown in D :\wwwroot\Web\php\Database.php on line 56"

In the config.php file i am specifying "type" => "Sqlserver" ( i have tried different case)

I have also tried creating an instance from Generator but that appears to generate both 1.7.4 and 1.8.0 at the same time. Any assistance would be very much appreciated.


User Permissions: Create multiple checkboxes each related to one bit of an integer field

$
0
0

We have a slew of pages that different users have different access to. Using Datatables Editor, is it possible to create a form that would allow for multiple checkboxes (64 max with 64-bit field) to be created ad related to one field?

The one field is a 'permissions' field, a 64-bit integer. We have it setup so that each bit that is set in the field grants access to a certain web page....like a users privileges in a database. I am hoping to create an admin page that will allow for simple assignment of user permissions via a checkboxe for each bit as opposed to the way I do it now.....manually, directly in the database.

Am I dreaming here or do I click 'Buy Now'?

Multiple tables in a Boostrap 4 row

$
0
0

I would like to get multiple tables in one Bootstrap 4 row. How to achieve this? If possible I would like to use the Bootstrap 4 class 'col' for this. For example:

      <div class="container-fluid">
        <div class="row">
          <div class="col">
            <h1>A</h1>
          </div>
          <div class="col">
            <h1>B</h1>
          </div>
          <div class="col">
            <h1>C</h1>
          </div>
        </div>
        <div class="row">
          <div class="col">
            <table id="" class="table myTable">
          </div>
          <div class="col">
            <table id="" class="table myTable">
          </div>
          <div class="col">
            <table id="" class="table myTable">
          </div>
        </div>
      </div>

Editor with select box column returns first value when editing other columns

$
0
0

I have an editor datable with inline editing, one of the columns has a select drop down. If while editing a column that isn't the select box, in the preSubmit event, the value for the selectbox column always is the first id in the select box list. i.e

    editor
        .on('preSubmit', function( e, o, a ) {
            console.log(a)
            data = o.data[Object.keys(o.data)[0]]
            data.subsystem = data.system_name
            data.system_name = Window.credsManager.teams[data.system_name]
        });

Duplicate Action resulting in simple edit instead of create

$
0
0

Using the code here

https://editor.datatables.net/examples/api/duplicateButton

Specifically

{
                extend: "selected",
                text: 'Duplicate',
                action: function ( e, dt, node, config ) {
                    // Start in edit mode, and then change to create
                    editor
                        .edit( table.rows( {selected: true} ).indexes(), {
                            title: 'Duplicate record',
                            buttons: 'Create from existing'
                        } )
                        .mode( 'create' );
                }

my local setup simply edits the row when I try to duplicate a record. The action is an edit and not a create.

I thought it might be because I was using an out of date library but have changed to 1.8 and the same thing happens.

Any ideas?

Compact table doesn't show all columns when screen too small

$
0
0

Hi,

I've been using DataTables in my project and I'm loving it so far. Unfortunately, I have a problem:

If my screen size is too small, the table will show a green + button to show the other columns. The last columns of my table are used as 'Actions' (Edit/Update/Delete) with an HTML icon so I don,t need to visualize the value inside this field (0):

I need it to look like this every time:

Any way to not let it resize? It causes a lot of problem for me. If by clicking the + button, it would show me my buttons and I can click on them, it would also work. Probably even better since the data would not be shrinked

Pattern to launch form from other form?

$
0
0

I have a backend database with a clients table and an events table. From the events table view, there will be an create/edit event form with select field to select an existing client. But if a new client is detected somehow ('new' button next to client select? simply type new client name in select window?), I'd like a client form to be launched over top of the events form to collect the client information and perform the ajax create client.

Is there any pattern I can look at that does something like this?

datatable refresh/reload with new data

$
0
0

Sample code below will load a datatable with pagination, search, sort properly the first time. When I try to call it again with new data it will load the data in a datatable with the controls but they won't work. I can't search or sort and the pagination doesn't work and it shows the data in one page. How can I get the controls to work properly when datatable is refresh/reloaded with new data?

Thank you

function loadBootStrapTable(data) {
    try {
        if (!isFirstLoad) {
            isFirstLoad = false;
            let t = $('#dataTableId').DataTable();
            t.rows().remove().draw(true);
        }

        let col = [];
        let table = document.getElementById("dataTableId");
        table.innerHTML = "";
        table.style.visibility = "visible";

        let header = table.createTHead();
        let tr = header.insertRow(0);
        for (let key in data[0]) {
            let th = document.createElement("th");
            th.innerHTML = key;
            tr.appendChild(th);
            col.push(key);
        }

        let body = table.createTBody();

        for (let i = 0; i < data.length; i++) {
            let tr = body.insertRow(0)
            for (let j = 0; j < col.length; j++) {
                let tabCell = tr.insertCell(j);
                tabCell.innerHTML = data[i][col[j]];
            }
        }
        if (true) {
            isFirstLoad = false;
            let t = $(document).ready(function () {
                $('#dataTableId').DataTable();
            });
            t.draw();
        }

        else {
            let t = $('#dataTableId').DataTable();
            t.draw(true);
        }
    }
    catch (e) {
        console.log(e.toString());
    }
}

Sorting on unique link text

$
0
0

I'm doing:

        this.api().columns([1]).every( function () {
            var column = this;
            var select = $('<select><option value="">Brands</option></select>')
            .appendTo( $(column.header()).empty() )
            .on( 'change', function () {
                var val = $.fn.dataTable.util.escapeRegex(
                    $(this).val()
                );

                column
                .search( val ? '^'+val+'$' : '', true, true )
                .draw();
            } );

            column.data().unique().sort().each( function ( d, j ) {
                // "d" IS A LINK, GET THE TEXT ONLY
                d = $(d).text();
                select.append( '<option value="'+d+'">'+d+'</option>' )
            } );
        } );

But... I want unique.sort on just the .text of the link. Can I give unique() options to use only the text?

Thanks! I'm fairly new to this...

Individual column searching (select inputs) + Ajax-ServerSide

$
0
0

Hello everyone, i have a problem implenting this filter. It only shows one page instead of all data.

Also i'm working laravel-adminlte

This's my index.blade.php (view)

@extends('adminlte::layouts.app')

@section('main-content')
    <!-- /*------------------CSS------------------*/ -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap.min.css">
    <!-- /*------------------CSS------------------*/ -->

    <!-- /*------------------Contenido------------------*/ -->
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header">
                        <h1 class="box-title"><b>Productos</b></h1>
                        @can('products.create')
                        <a href="{{ route('products.create') }}"><i class="btn btn-sm btn-success fa fa-plus-circle pull-right"> Crear</i></a>
                            <!-- <a href="{{  route('products.create')  }}" class="btn  btn-primary fa fa-plus-circle">Crear</a> -->
                        @endcan
                    </div>
                    <div class="box-body">
                        <table class="table table-responsive table-striped table-bordered" id="products">
                            <thead>
                                <tr>
                                    <th width="10px">ID</th>
                                    <th>Nombre</th>
                                    <th>Descripcion</th>
                                    <th>&nbsp;</th>
                                </tr>
                            </thead>
                            <tfoot>
                                <tr>
                                    <th width="10px">ID</th>
                                    <th>Nombre</th>
                                    <th>Descripcion</th>
                                    <th>&nbsp;</th>
                                </tr>
                            </tfoot>
                        </table>
                    </div> <!-- /.box-body -->
                </div> <!-- /.box -->
            </div>
        </div>
    </section>
    <!-- /*------------------Contenido------------------*/ -->

    <!-- /*------------------Script------------------*/ -->
    <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
    <script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
    <script src="https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap.min.js"></script>

    <script>
        $(document).ready( function () {
            $('#products').DataTable({

                // "dom": '<"row"<"col-sm-4"l><"col-sm-6"f>>t<"col-sm-6"p><i>',
                "serverSide":true,
                "ajax": "{{ url('api/products') }}",
                "columns":[
                    {data: 'id'},
                    {data: 'name'},
                    {data: 'description'},
                    {data: 'btn'},
                ],

                initComplete: function () 
                {
                    this.api().columns([0,1,2]).every( function () //Columnas a mostrar
                    {
                        var column = this;
                        var select = $('<select><option value=""></option></select>')
                            .appendTo( $(column.footer()).empty() )
                            .on( 'change', function () {var val = $.fn.dataTable.util.escapeRegex($(this).val());
                            column
                            .search( val ? '^'+val+'$' : '', true, false )
                            .draw();
                        });
                        column.data().unique().sort().each( function ( d, j ) 
                        {
                            select.append( '<option value="'+d+'">'+d+'</option>' )
                        });
                    });
                }
                
            });
        });
    </script>
    <!-- /*------------------Script------------------*/ -->


    @endsection

And this's how it's shows

Hope you can help me

Bubble editing - how do you set up a multiple select dropdown menu?

$
0
0

Can you point me to an FAQ or example code for how to set up a multiple select menu in the bubble editor? The assumption is that I would use the control key to select multiple items (or perhaps shift+ ). The plan - I'm setting up a function which will make it possible to select all, all but, none or individual items in a list.

This may involve adding two functions - one a simple dropdown for 'all', 'all but', 'none'. The second would be the multiselect list of choices - the subject of this question.

hide show column complex header table

$
0
0

hello everyone i am having a problem about hiding the current column for the complex table, can someone give me the key word or tutorial i get

Converting mysql server-side to mssql

$
0
0

Hi I am trying to convert mysql server-side to mssql server siide I've managed to get the output but I was having issue in this code.

$sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." offset ".$requestData['start']." fetch next ".$requestData['length']." rows only ";

Any thoughts?

Viewing all 82295 articles
Browse latest View live


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