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

Custom field in Editor Serverside script

$
0
0

Hi,
when using serverside, i want in the serverside script to to make-use a custom Editor field (dates-datetime difference in HH:mm ) so that it can be easily sorted in the Datatable.
I currently have it as rendered column in Datatable ,but i can't sort it since it does not exist in the Serverside Editor script .

Thank you.


options for select drop-down are blank

$
0
0

I have three datatables on a page, two of which have left joins and have a pull-down field. One, the options are getting created correctly. The other one, no options array is created:

This one works:

                public class LineItemsController : ApiController
                {
                    [Route("api/LineItems")]
                    [HttpGet]
                    [HttpPost]
                    public IHttpActionResult LineItems()
                    {
                        var request = HttpContext.Current.Request;
                        var settings = Properties.Settings.Default;

                        using (var db = new Database(settings.DbType, settings.DbConnection))
                        {
                            var response = new Editor(db, "InvoiceStructure_LineItems", "LineItemID")
                                .Model<LineItemsModel>("InvoiceStructure_LineItems")
                                .Model<LineItemCategoryModel>("InvoiceStructure_Categories")
                                .Field(new Field("InvoiceStructure_LineItems.LineItemID"))
                                .Field(new Field("InvoiceStructure_LineItems.LineItem")
                                    .Validator(Validation.NotEmpty())
                                )
                                .Field(new Field("InvoiceStructure_LineItems.CategoryID")
                                    .Validator(Validation.NotEmpty())
                                    .Validator(Validation.Numeric())
                                    .Options("InvoiceStructure_Categories","CategoryID","Category")
                                )
                                .Field(new Field("InvoiceStructure_LineItems.sortby")
                                    .Validator(Validation.NotEmpty())
                                )
                                .LeftJoin("InvoiceStructure_Categories", "InvoiceStructure_LineItems.CategoryID", "=", "InvoiceStructure_Categories.CategoryID")
                                .Where("InvoiceStructure_LineItems.CategoryID", request.Form["InvoiceStructure_LineItems.CategoryID"])
                                .Process(request)
                                .Data();

                            return Json(response);
                        }
                    }
                }

correctly returns:

{draw: null,…}
draw: null
data: [{DT_RowId: "row_12",…}, {DT_RowId: "row_13",…}, {DT_RowId: "row_14",…}, {DT_RowId: "row_15",…},…]
0: {DT_RowId: "row_12",…}
1: {DT_RowId: "row_13",…}
2: {DT_RowId: "row_14",…}
3: {DT_RowId: "row_15",…}
4: {DT_RowId: "row_16",…}
DT_RowId: "row_16"
InvoiceStructure_LineItems: {LineItemID: 16, LineItem: "GIS Direct", CategoryID: "3", sortby: "5"}
LineItemID: 16
LineItem: "GIS Direct"
CategoryID: "3"
sortby: "5"
InvoiceStructure_Categories: {CategoryID: 3, category: "Direct Charges (Variable Costs)", sortby: "3"}
CategoryID: 3
category: "Direct Charges (Variable Costs)"
sortby: "3"
5: {DT_RowId: "row_17",…}
recordsTotal: null
recordsFiltered: null
error: null
fieldErrors: []
id: null
meta: {}
options: {InvoiceStructure_LineItems.CategoryID: [{value: 2, label: "Direct Charges (Fixed Costs)"},…]}
InvoiceStructure_LineItems.CategoryID: [{value: 2, label: "Direct Charges (Fixed Costs)"},…]
0: {value: 2, label: "Direct Charges (Fixed Costs)"}
1: {value: 3, label: "Direct Charges (Variable Costs)"}
2: {value: 1, label: "Indirect Charges"}
3: {value: 4, label: "Project Charges"}
4: {value: 5, label: "Telecom - Phone lines"}
5: {value: 7, label: "Telecom - Purchase / Labor Charges"}
6: {value: 6, label: "Telecom - Recurring Charges"}
files: {}
upload: {id: null}
debug: null
cancelled: []

This one does not

                public class BillingSetup_UnitRatesController : ApiController
                {
                    [Route("api/BillingSetup_UnitRates")]
                    [HttpGet]
                    [HttpPost]
                    public IHttpActionResult BillingSetup_UnitRates()

                    {
                        var request = HttpContext.Current.Request;
                        var settings = Properties.Settings.Default;

                        using (var db = new Database(settings.DbType, settings.DbConnection))
                        {
                            var response = new Editor(db, "BillingSetup_UnitRates", "UnitRateID")
                                .Model<BillingSetup_UnitRatesModel>("BillingSetup_UnitRates")
                                .Model<LineItemsModel>("InvoiceStructure_LineItems")
                                .Field(new Field("BillingSetup_UnitRates.effectivedate"))
                                .Field(new Field("BillingSetup_UnitRates.expiredate"))
                                .Field(new Field("BillingSetup_UnitRates.unitrate"))
                                .Field(new Field("BillingSetup_UnitRates.LineItemID")
                                    .Validator(Validation.NotEmpty())
                                    .Validator(Validation.Numeric())
                                    .Options("InvoiceStructure_LineItems","LineItemID","LineItem")
                                 )
                                .LeftJoin("InvoiceStructure_LineItems", "InvoiceStructure_LineItems.LineItemID", "=", "BillingSetup_UnitRates.LineItemID")
                                .Where("BillingSetup_UnitRates.LineItemID", request.Form["BillingSetup_UnitRates.LineItemID"])
                                .Process(request)
                                .Data();
                            return Json(response);
                        }
                    }
                }

returns no options

{draw: null, data: [{DT_RowId: "row_3",…}], recordsTotal: null, recordsFiltered: null, error: null,…}
draw: null
data: [{DT_RowId: "row_3",…}]
0: {DT_RowId: "row_3",…}
DT_RowId: "row_3"
BillingSetup_UnitRates: {LineItemID: "16", effectivedate: "7/1/2012 12:00:00 AM", expiredate: null, unitrate: "307.41"}
LineItemID: "16"
effectivedate: "7/1/2012 12:00:00 AM"
expiredate: null
unitrate: "307.41"
InvoiceStructure_LineItems: {LineItemID: 16, LineItem: "GIS Direct", CategoryID: "3", sortby: "5"}
LineItemID: 16
LineItem: "GIS Direct"
CategoryID: "3"
sortby: "5"
recordsTotal: null
recordsFiltered: null
error: null
fieldErrors: []
id: null
meta: {}
options: {}
files: {}
upload: {id: null}
debug: null
cancelled: []

duplicate scrollbar in the header : datatable and scrollX

$
0
0

Hi all,

I have a datatable with scrollX option so i have a scrollbar in the bottom of my table.
I am looking for a solution to duplicate scrollbar on the top of my table

Anybody have a solution to duplicate this scrollbar on the top ?

No type was found that matches the controller named ...

$
0
0

I created a simple sql table to add a datagrid to an existing project. The existing project was created using the Editor Generator and the existing grids work fine. The new grid I tried adding gives me the error:

No type was found that matches the controller named 'test'

When I use the Generator to create a new project with this sample test grid it loads just fine. I then merely copy/pasted the code form the new project to the existing project and I still got the 'no type found' error. Why does it work on a stand-alone project created by the generator but not when added to an existing project. does the generator do some type of registering that I need to do manually when adding a grid?

Conditions MJoin

$
0
0

I am trying to use a condition on the Joined table with MJoin - I do not want to show archived entries - but it does not work. What do I do wrong?

Thanks in advance!

// Build our Editor instance and process the data coming from _POST
$editor = Editor::inst($db, 'as_users', 'user_id');

########
# Joins
// für die as_user_details
$editor->leftJoin( 'as_user_details as details', 'as_users.user_id', '=', 'details.user_id' );

// as_user_roles
$editor->leftJoin('as_user_roles as roles', 'as_users.user_role', '=', 'roles.role_id');

// Join für den Namen des Users, der dein Eintrag erzeugt hat
$editor->leftJoin('as_user_details as created_details', 'as_users.created_by_user_id', '=', 'created_details.user_id');

// Join für die Qualifikationen 1:n

$editor->join(
    Mjoin::inst('qualifications_names')
        //->validator('qualifications_names[].id', Validate::mjoinMinCount(1))
        ->link('as_users.user_id', 'link_as_users__qualifications_names.user_id')
        ->link('qualifications_names.id', 'link_as_users__qualifications_names.qualification_names_id')
        // TODO archivierte nicht anzeigen
        //->order('name asc')
        ->fields(
            Field::inst('id')
                ->set(Field::SET_NONE)
                ->validator(Validate::required())
                ->options(Options::inst()
                    ->table('qualifications_names')
                    ->value('id')
                    ->label('qualification_name'),
                Field::inst('qualification_name')
                )
        )
        ->where("qualifications_names.archived", "1", "!=")
);

Filtering and export issues

$
0
0

Hi,
so I'm new to the .net in general and to the datatable. I want to view data from multiple tables in one view, that's why I'm using ViewModel and two partial view _Department, _Permission and I render them from a third main view called myInfo.
I want to initialize each one of them as a datatable that has its own EXPOrt as an excel sheet and filtering.
the problem is only the department that the datatable applied in it . for simplicity I kept only one partial view to make as a data table. still the filtering not working and the export only gets the first column only in the excel sheet. I used developer tool to check if there is any error there wasn't I don't know where is my mistake. I appreciate any help <3 .

myInfo view:

<div class="x_content">
                                        <h3> Department</h3>
                                        @{Html.RenderPartial("~/Views/UserPermission/PartialViews/_Department.cshtml", ViewData.Model.Departments);}
                                    </div>

_Department view:

<table class="table " id="ViewData">
    <thead>
        <tr>
            <th>
                <b>
                    @Html.DisplayNameFor(model => model.Dep_Name)
                </b>
            </th>
            <th>
                <b>
                    @Html.DisplayNameFor(model => model.UserId)
                </b>
            </th>
        </tr>
    </thead>
    @foreach (var item in Model)
    {
        <tbody>
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.Dep_Name)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.UserId)
                </td>
            </tr>
        </tbody>
    }
</table>
          

<script>
    $(document).ready(function () {
        $('#ViewData').DataTable({
            dom: 'Bfrtip',
            "buttons": [
                'copy', 'excel'
            ]
        });
    });
                           
</script>********

Setting header in AJAX request

$
0
0

I keep searching and hacking away at this, but can't figure out how to send headers to the AJAX request.

    ajax: {
        url: url,
        headers: {
            "Accept" : "application/ld+json",
            "Content-Type": "text/json; charset=utf-8"
        },
        beforeSend: function (request) {
            console.error(request);
            request.setRequestHeader("Accept", 'application/ld+json');
        },

The AJAX call is made to the URL, but the headers aren't correct, and beforeSend isn't called. (not show: dataFilter, which also doesn't seem to be called). The ajax object is passed on directly to jquery, right? The only exception is to not override the success call, which datatable uses internally, right?

Thanks,

Tac

Set width of ONE Column Header while initialising

$
0
0

Hello,

Is it possible to set the width of one column to a set size?

I have the first column as a context menu button and need it to be much smaller than what it is now.

Thanks,


my server side data table width gets half sometimes dont know why, any solution??

How to change the width of a child row

How to add row index to after rowGroup ?

$
0
0

$(document).ready(function() {
$('#example').DataTable( {
order: [[2, 'asc']],
rowGroup: {
startRender: null,
endRender: function ( rows, group ) {
return row_group_index + ' ' + group +' ('+rows.count()+')';
},
dataSrc: 2
}
} );
} );

ask u can see the example above I would like to add the row_group_index (1, 2, 3, 4, .etc...) along with the row group label like so. How can I do that ? Thank you.

with this example below I just want to add the row grouping index before each row grouping label.
https://datatables.net/extensions/rowgroup/examples/initialisation/endRender.html

scrollY with individual column searching (text inputs) in the header and set the value of the input

$
0
0

Hello,

After using scrollY I'm not able to put individual column searching (text inputs) in the header and can't set the value of the input with val(); also anymore. Test page:

http://live.datatables.net/yuvuhate/1/edit

For example line 167; I can't set the value of every matched element.

About the individual column searching (text inputs) in the header (related posts):
https://datatables.net/forums/discussion/30936
https://datatables.net/forums/discussion/35673
https://datatables.net/forums/discussion/comment/146190/#Comment_146190

I tried the trick of colin (without 100% working):

http://live.datatables.net/diwapewa/33/edit

Could I get help with this things?

Thanks,

Mark

Individual column searching (text inputs) does not show input text after page changing

$
0
0

Hello,

I’m using the “Individual column searching (text inputs)” explained in

https://datatables.net/examples/api/multi_filter.html

but I have a problem.

When I change page and later come back, the values written inside the input controls are not displayed. The filters work (i.e. the columns contain only the filtered results), but the searched words are not visibile. The global Search is instead populated.

In DataTable constructor I set:

  `stateDuration: -1, //-1 means session storage
  `stateSave: true, 

and

    `initComplete: function () {
    `var r = $('#myTableId tfoot tr');
      `r.find('th').each(function(){
        `$(this).css('padding', 8);
      `});
      `$('#myTableId thead').append(r);
      `$('#search_0').css('text-align', 'center');

      `var api = this.api();

      `// Apply the search
      `api.columns().every(function() {
        `var that = this;       
        `$('input', this.footer()).on('keyup change', function() {
          `if (that.search() !== this.value) {
            `that.search(this.value).draw();
          `}
            `});
        `});
     `},

Could anyone help me figure out where I'm wrong?

Thanks in advance, Leonardo

Why is filtering/searching not firing the Processing event?

$
0
0

I've set up the processing dialog in my table definition and the message comes up fine when I sort a column. Unfortunately, the processing event doesn't fire when I use the search box or programatically filter the columns. The reference manual says "This event is fired when DataTables is doing some kind of processing - be it, sorting, filtering or any other kind of data processing".
Am I wrong to assume that it should fire for search or filtering? I know that the column filtering is really column searching so I figured the search box should also fire the processing event. I was also wondering if paging should fire the processing event?
Thanks.

Multi Filtering by column on serverside table

$
0
0

hey guys i've made a datatable using serverside with ajax however I'm not able to user column filtering i just doesn't work.

this is my code

var dataTableChamado = $('#arquivos3').DataTable({
        "order": [[ 3, "desc" ]],
        "processing": false,
        "lengthChange": true,
        "lengthMenu": [[10, 25, 50, 10000000], [10, 25, 50, "Todos"]],
        "dom": 'lBfrtip',
        "buttons": [
            {extend: 'excel', title: 'Logic - Todos Chamados'},
            {extend: 'pdf', title: 'Logic - Todos Chamados'}
        ],
        "columnDefs": [ {
            "targets": 1,
            "render": function ( data, type, row ) {
              return '<a href="chamado.php?id='+row[0]+'">'+data+'</a>';
            }
          },
          { className: "my_class", "targets": [ 0 ] },
          {
            "targets": 0,
            "render": function ( data, type, row ) {
              return '<a href="chamado.php?id='+row[0]+'">'+data+'</a>';
            }
          },
          {
            "targets": 8,
            "render": function ( data, type, row ) {
                if(data==1){
                    return '<span>Aberto</span>';
                }
                if(data==2){
                    return '<span>Fechado</span>';
                }
            }
          }],
        "serverSide": true,
        "ajax": {
            url: "includes/tabelaChamado.php", // json datasource
            type: "post", // method  , by default get
        },
        "initComplete": function() {
            var $buttons = $('.dt-buttons').hide();
            $("#pdf").on("click", function() {
                $('.buttons-pdf').click();
            });
            $("#excel").on("click", function() {
                $('.buttons-excel').click();
            });
            
            this.api().columns().every( function () {
                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>' )
                } );
            } );
            
       }
    });

on initComplete I call all the footer selects to filter and the draw function but it still not working.

hope you guys can help me.


How can we search a null value with serverside (table.columns(12).search('^$', true, false)) ?

$
0
0

Hi,

I tried and searched to search a null value with a serverside.

In my JSON (return by the php file form the editor), my field is like this {"FIELD": null}.
I saw in the documentation that I need this line to search in a column :
table.columns(12).search('^$', true, false).draw();

However, it doesn't work (normally '^$' to found an empty or null value. I tried too '^\s*$'). I can just search a string (ex : 'TOTO' or '^TOTO$' and here, it's working).

I think that we can search only on string value ... Can you confirm that or, if we can search a null value, how can we do it ?

Form what I saw, we can't search a null value, but topics was a little old. I hope that since, a release already add this feature :smile:

Thanks
BR
Xavier

Use the export options while getting data with server side

$
0
0

Dear all,
is there a way to export to pdf or excel when binding the grid from server-side API.
I'm using angular CLI for development and referring to those tutorials:
server-side
export buttons

When exporting, sheets are only containing the headers titles

Thanks in advance and any reply is well appreciated.

Regards,
Hassan Kobeissi

Multi-level grouping, break

$
0
0

hey i used Multi-level grouping, its work ok, but the second grouping sometimes break
i upload a picture to understand,the circle in black is the same mainSubject but not in one group

Incorrect sorting in Russian lang

Change data source dynamically

$
0
0

Good afternoon,

New with Datatables and Jquery, so maybe my question is naive. Here I go: I would like to have a <select> which allows me to select the source database table (and so the columns) showed in the table.

Any advice or suggestion?

Kind regards,

David

Viewing all 81365 articles
Browse latest View live


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