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

Changing parameters for datatable loaded with fnserverdata

$
0
0

I'm using the following function to load a DataTables table with data from the server. I would like to reload the table with different parameters on a click event only i cant work out how to do this. If i call reload it just reloads with the original parameters if i reinitialise the whole table it throws an error as the table already exists.

I have been looking into fnServerParams but cant work out if it would help or not.

If anyone can point me in the correct direction that would be great.

function LoadRiskProfileModalTable(userId, teamId, riskProfileClass) {

var params = {
    userId: userId,
    teamId: teamId,
    riskProfileClass: riskProfileClass
};

var data = JSON.stringify(params);
//if (!$.fn.DataTable.isDataTable("#riskProfileTable")) {

    var table = $("#riskProfileTable").DataTable({
        "bProcessing": true,
        "sAjaxSource": "WFMHome.aspx/GetRiskProfileDrillThroughDatatable",
        "fnServerData": function (sSource, aoData, fnCallback) {
            //aoData.push(JSON.stringify(params));
            $.ajax({
                "dataType": 'json',
                "contentType": "application/json; charset=utf-8",
                "type": "POST",
                "url": sSource,
                "data": data,
                "success": function (msg) {
                    var json = jQuery.parseJSON(msg.d);
                    fnCallback(json);
                    $("#riskProfileTable").show("fast", function () { $('#riskProfileTableLoading').hide("fast") });
                },
                error: function (xhr, textStatus, error) {
                    if (typeof console == "object") {
                        appendAlert("errorAlertPlaceholder", xhr.responseText, 1, "danger");
                        console.log(xhr.status + "," + xhr.responseText + "," + textStatus + "," + error);
                    }
                }
            });
        },
        "columns": [
            { "data": "CaseHandler" },
            { "data": "caseAreaText" },
            { "data": "RiskProfileText" },
            { "data": "PassChecks" },
            { "data": "F1Checks" },
            { "data": "F2Checks" },
            { "data": "F3Checks" },
            { "data": "CurrentChecks" }
        ]
    });
//}
//else {
//        $('#riskProfileTable').DataTable().ajax.reload();
//    }
};

Can I use Exists as a condition in Editor .Net?

$
0
0

Hi,

I am trying to do something like this. The only part I am missing is the exists, also I am not sure if I can use the SQL function fncGetHREmployees.

How can I do the exists

select
    sig.EvaluationId As ReviewId, eva.CreationDate, eva.DepartmentName, eva.PositionName, emp.FullName, eva.ManagerName, sig.ResponsibleId
from SignOff sig
    inner join  Evaluation eva
        on sig.EvaluationId = eva.Id
    inner join organization org
        on eva.organizationid = org.id
    inner join employee emp
        on org.Employeeid = emp.Id
where exists (select EmployeeId from fncGetHREmployees(10) fnc where sig.ResponsibleId = fnc.EmployeeId)    and
    AdHoc = 0 and IsClosed = 0

At the moment I have got something like this.

 using (var dtDB = new DataTables.Database("sqlserver", conn))
            {
                var response = new Editor(dtDB, "Evaluation", "Id")
                    .Model<VMReviewsManagerHR>()
                    .Field(new Field("Evaluation.DepartmentName")
                        .Validator(Validation.None())
                    )
                    .Field(new Field("Evaluation.PositionName")
                        .Validator(Validation.None())
                    )
                    .Field(new Field("Employee.FullName")
                        .Validator(Validation.None())
                    )
                    .Field(new Field("Evaluation.ManagerName")
                        .Validator(Validation.None())
                    )
                    .Field(new Field("SignOff.ResponsibleId")
                        .Validator(Validation.None())
                    )
                    .LeftJoin("Organization", "Evaluation.OrganizationId", "=", "Organization.Id")
                    .LeftJoin("Employee", "Organization.EmployeeId", "=", "Employee.Id")
                    .LeftJoin("SignOff", "Evaluation.Id", "=", "SignOff.EvaluationId")
                    .Where("Evaluation.AdHoc", "0")
                    .Where("Evaluation.IsClosed", "0")
                    .Where(q => q.Where(**EXISTS HERE**))
                    .Process(request)
                    .Data();

                return Json(response, JsonRequestBehavior.AllowGet);
            }

Thanks,

Wilson

Autocomplete with inline editing

$
0
0

Hi,

I am trying to use autocomplete together with inline edit icon. If I click the New or Edit buttons autocomplete works. However, when using inline editing I can't save the changes for autocomplete fields and textfields (it works for text fields). The autocomplete values are shown and can be selected but I can't save them by pressing Enter. And in textfields Enter gives, of course, a new row. How can it be solved so I can save all changes made inline?

I don't want to paste the code here, but can send it to Allan if needed.

Method to add new row to a particular page

$
0
0

Is there any way by which we can add a new row to a particular page? I am using the bootstrap uid-pagination for my custom pagination which fetches records from backend. If i click on page 4, it returns me records with index 40 to 49, which is expected and runs fine. The only problem is, when I say table.page( 3 ).draw( 'page' );, the datatable does not show any records on that page. (This must be because the datatable has not yet build the page 3. After table.rows.add(), the total number of pages was just 2 with total 20 records).

Is there a way so that i can tell the datatable to directly add these records on page 4?

num-html does not work

Custom selector for click blur

$
0
0

I love the blurable feature but I miss the ability to specify elements that should not cause key-blur. Right now, the rules are as follows:
* Click on the search input will blur focus
* If the click was inside the DataTables container, don't blur
* Don't blur in Editor form
* Or an Editor date input
* If the click was inside the fixed columns container, don't blur

I would like there to be an option to configure a jQuery selector for elements that, when clicked, should not cause key-blur.

$('#example').DataTable({
  keys: {
    columns: ':not(:first-child)',
    blurable: true,
    blurableIgnore: '.no-keyblur'
  }
});

I need this feature for custom controls outside the table wrapper that interact with the selected cell.

I already added this feature to my fork: https://github.com/StevenLiekens/KeyTable/commit/a4aec3b22dbdbce6b3c656bc4e3eabf68212fd0a

Jquery Datatable with server side processing and knockout

$
0
0

Hi, i am new at jquery datatbles. I have a problem in jquery datatables with server processing and knockout binding. Can anybody help me how we can bind jquery datatables with knockout and server side processing true. data displayed when i add json data in obserbable array but no paging so how to set total records in this case for paging .
knockout work fine when we load all data using serverside processing false

How to align specifiek datatables to left

$
0
0

Hi i'm a newbee when it comes to datatables, but I can't figure out how to resolve this issue. When I use datatables the wrapper always centers my table. But I want on some pages (not all) that the datatable is not centered but left aligned.

How can I achieve this?


Deleting a row in joined table generate an SQL error. What do I do wrong?

$
0
0

I have 2 tables. One (otc_transport) stores useful info. The second ('otc_transport_ord')is a link table that stores which transport is associated with a particular shipment order. So the link table has 2 columns: id_order and id_transport.
In my table, I need to display the list of transports, to add, edit and delete. As the table is in the current order page, the id_order is set directly.

I tried first the version with simple join.
I can add rows, I can edit rows, I can NOT delete a row.
Error when I confirm deleting the row is:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'otc_transport.id_transport' in 'where clause'

Here is the code:

Editor::inst( $db, 'otc_transport', 'id_transport' )
    ->fields(
        Field::inst( 'otc_transport.id_transport'),
                Field::inst( 'otc_transport_ord.id_order' ) ->setValue( $_GET['id_order']),
// useful fields:
        Field::inst( 'otc_transport.id_type' ),
        Field::inst( 'otc_transport.name' )->validator( 'Validate::notEmpty' ),
// more fields....
    )
    ->leftJoin( 'otc_transport_ord',   'otc_transport_ord.id_transport',   '=', 'otc_transport.id_transport' )
    ->where( 'otc_transport_ord.id_order', $_GET['id_order'] )
    ->process($_POST)
    ->json();

then I tried the Mjoin version for direct link as described in One-to-many joins documentation, but i get the warning:

DataTables warning: table id=tabel_transport - Table selected fields (i.e. '{table}.{column}') in Join must be read only. Use set(false) for the field to disable writing

Editor::inst( $db, 'otc_transport', 'id_transport' )
    ->fields(
        Field::inst( 'otc_transport.id_transport' ),
// useful fields:
        Field::inst( 'otc_transport.id_type' ),
        Field::inst( 'otc_transport.name' )->validator( 'Validate::notEmpty' ),
// more fields....
    )
    ->join(
        Mjoin::inst( 'otc_transport_ord.id_transport','otc_transport.id_transport' )
            ->fields(
                Field::inst( 'otc_transport_ord.id_order' ) ->setValue( $_GET['id_order'])
            )
    )
    ->process($_POST)
    ->json();

so..... what am I missing? What do I do wrong?
Why, if I can create a transport and the link tables is updated and all works perfect, I can not delete it? It makes no sense to me.

Other info:
1. Editor version is 1.6
2. I have no other bugs, all info are sent correct. Proof is that create and edit works ok.
3. if I remember well the delete was also working when I first created the table. We discover the bug now, on final testing. Maybe I did not had 1.6 back then? Can not tell for sure.
4. Debug with file_put_contents returns a wrong SQL: sql DELETE FROM `otc_transport` WHERE (`otc_transport`.`id_transport` = :where_1 AND `otc_transport_ord`.`id_ord` = :where_2 )

Can i add the custom message in the same row as the title in pdfhtml5 export

$
0
0

I have the title left aligned, now i want to add the message on the same row but right aligned:

extend: "pdfHtml5", className: "btn-sm", orientation: 'portrait', pageSize: 'LETTER', title: '@Localizer["MERCHANT REPORT"]', exportOptions: {
columns: [0, 1, 2, 3, 4]
},
message: 'Dashboard ',
customize: function (doc) {

                     doc.content[2].table.widths = ['40%', '15%', '20%', '15%', '10%'];

                     doc.defaultStyle.fontSize = 8;

                     doc['footer'] = (function (page, pages) {
                         return {
                             columns: [
                             '@Localizer["REPORT DATE:"]' + ' ' + moment().format('YYYY-MM-DD, HH:mm:ss') + '',
                             {
                                 alignment: 'right',
                                 text: [
                                 { text: page.toString(), italics: true },
                                 ' of ',
                                 { text: pages.toString(), italics: true }
                                 ]
                             }],
                             margin: [10, 0]
                         }
                     });
                 }
             },

multiple related tables

$
0
0

I'm not really sure how to ask this (which is likely why I am stuck).

I have two separate MySQL tables called "SERVER" and "VOLUME." In the SERVER table, there is a foreign key for the VOLUME table. Vice versa in the VOLUME table. It is simple enough to do the left joins and set those up on their own, no issue there.

What I would like to do is when I edit the SERVER table with a particular VOLUME, the VOLUME table also correctly references the SERVER. Does that make sense?

e.g. If I set this on the SERVER table
SERVER
id=1
name=myserver
volume_id=2 (the foreign key)

I would like when I set the volume_id above, it does this on the VOLUMES table:
VOLUMES
id=2
name=myvolume
server_id=1 (the foreign key)

Large Decimal in Column

$
0
0

I have an ID returning from an ajax call.... The JSON data coming in looks fine, but then the data in the column is displaying
1.0072101200000002e+23 instead of 100721012000000028180956

Please how do I fix this (I looked at .toFixed() but that only supports up to 20 digits) and anything that is called in mRender truncates the number to 1007210120000000281

Add/Remove a search criteria among others

$
0
0

Hello,

I'm using textfields to perform filtering among columns like in this example. I added on the top of the table a checkbox which, when checked, should only display lines where the column named "ms" is not empty. I do a simple table.column("ms:name").search("^\s*$", true).draw(); when the checkbox is checked and a table.column("ms:name").search("").draw(); when unchecked.

BUT now, I remark that :
1) i check the checkbox and the correct lines are shown in the table
2) I write something in the textbox of a column to filter the displayed results ; It works...
3) I remove what I wrote in this textbox and I see that ALL lines appears, even those who don't match "^\s*$" criteria : the checkbox is now forgotten !

And now I understand that the search criteria first written in the column textfields are also forgotten when, after, I check the checkbox since checking this checkbox does not ADD a search criteria but DEFINES (and overwrites) existing search criteria.

How can I do to ensure that the criteria set by the checkbox is always filtering the table until the checkbox is unchecked ??

Is there a way to ADD/REMOVE search criteria to those who already exists ?

Thanks for your help !

t.

Excel Column width

$
0
0

I tried searching for this but all I am finding references TableTools... is there anyway to make the export function for Excel using Buttons to set the column width? I would really like for it to just autowidth.

Reload Datatable from JSON populated dropdown menu selection.

$
0
0

I'm trying to reload the datatable information from a drop down menu selection. The data in the drop down selection is a JSON array of objects being called from a REST service.

Here is a working test application:

tcloud.iowadot.gov/highway/weatherview/

Click on the green point, then click on the forecast tab. The drop down menu change is supposed to change the data in the datatable according to the new selected element. But it's not changing the data.

Here is my datatable initialization:

$(document).ready(function() {
    $('body').on('click','.tabLabel', function() {
        $('#forecast-table').DataTable({
        searching: false,
        scrollY: "40vh",
        scrollCollapse: true,
        paging: false,
        responsive: true,
        info: false,
        autoWidth: true,
    });
  });
});

if you need more code, let me know.

Thanks in advance!


Date field localization issue

$
0
0

I have a CRUD management application, which I've obtained using the DTE generator. One of the fields is of date type, which I want to give a specific format, with these elements:

  • Moment.js (included in the whole DTE package by generator)
  • Plugin datetime.js (written by Allan Jardine)
  • Plugin datetime-moment.js (written by Allan Jardine)

In file 'table.mapi.js' (DTE generator), I add these lines

moment.locale('es'); // Chage locale to spanish
$.fn.dataTable.moment( 'ddd, D MMM YYYY', 'en' ); // Call function to give format to datetime field -- note that if I put 'es' on locale parameter, order doesn't work (some plugin compatibility issue?)

after $(document).ready(function() {

then, I define ('fields' param of var editor) the following:

"label": "Fecha:",
"name": "fecha",
"type": "datetime",
"def": function () { return new Date();},
"format": "ddd, D MMM YYYY",
"opts": { "showWeekNumber": false, "momentLocale": 'es' }

and

"data": "fecha",
"render": function ( data, type, full, meta ) { if (type === 'display') { if (data) { var mDate = moment(data); data = (mDate && mDate.isValid()) ? mDate.format("LL") : ""; } } return data; }

('columns' param of datatables), to get date displayed on large format.

Till now, all this works fine. The problem arrives on "New" record button's hand, when I fill in the fields (selecting desired date on datepicker) and then I press "Save" button, validator shows the following error:

"Date is not in the expected format", and, obviously, doesn't perform the op (save data to mysql db).

In addition, when I select one row, in order to edit its data, the modal edit form shows the fields; but date field is still on default locale ('en').

I suposse this is due to issues with format specified in date validator, since I've left the defaults created by DTE generator (except empty field validation, that's been customized), so:

Field::inst( 'fecha' )
->validator( function ( $val, $data, $opts ) { return empty( $val ) ? 'Este es un campo requerido' : true; } )
->validator( 'Validate::dateFormat', array( 'format'=>'D, j M Y' ) )
->getFormatter( 'Format::date_sql_to_format', 'D, j M Y' )
->setFormatter( 'Format::date_format_to_sql', 'D, j M Y' ),

What's the correct validation in this case? Do I need configure some kind of i18n on PHP settings in validation module, such as Moment 'locale'?

Thanks in advance

pdf make document on https site

$
0
0

i recently updated a site with ssl, so all links and pages now use https://

i use buttons and pdfmake to create an on the fly invoice creator, but the generated page (in chrome) indicates the page is not secure. its not really a big deal, as there is obviously no data input, but I wondered if there is anything I can do about it.

the generated url is data:application/pdf;base64,JV......

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.

How do you implement a search like this without using the data table?

$
0
0

So angular has a built in filter, however how are you able to type part of a word hit space and then filter other columns?

Editor Create Button Stopped Working

$
0
0

Hey,

Recently I updated Datatables+Editor to the latest version and today I've noticed that "Create" button stopped working. When I click the button, instead of opening the editor, it will redirect me to "/businesses/create" page (although I can't find that URL/path anywhere in my code, and route doesn't exist for that URL), and without triggering "open" or "initEdit" event. Strange thing is that "Edit" button and others work as they should. Another thing to mention is that this happens on all (3) pages that use buttons.

I've spent a lot on trying to solve this; initially I thought it may be a bug in latest version but dowgrading to previous version confirmed it's not, since bug still seemed to exist. I've wen't through old code looking for changes that could cause this, but I can't find the problem, that's why I wanted to ask here.

Any suggestion how to debug this problem or idea why this would happen?

Versions:
"datatables.net-bs": "~2.1.1",
"datatables.net-responsive-bs": "~2.1.1",
"datatables.net-buttons-bs": "~1.2.4",
"datatables.net-buttons-dt": "^1.2.4",
"datatables.net-select-bs": "~1.2.1",
"datatables.net-fixedheader-bs": "~3.1.2",
"datatables.net-colreorder": "^1.3.2",
"jQuery": "~1.12.4",
DataTables Editor: 1.6.1

Viewing all 81403 articles
Browse latest View live


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