Problem hiding column.

Problem hiding column.

flyingdogmdflyingdogmd Posts: 2Questions: 1Answers: 0

Hi All,

I'm having some troubles hiding a column and I'm looking for some advice. What I've noticed is that the column is hidden before my ajax data source loads (during processing) but appears again after loading.

I've tried using both columnDefs:

"columnDefs": [{ "visible": false, "targets": 0 }]

And column:

"columns": [{ "visible": false, "data": "ColumnName" }

But still no resolve. Has anyone else had this problem by chance?

Answers

  • tangerinetangerine Posts: 3,350Questions: 37Answers: 394

    Your syntax is wrong. Check the examples (e.g. columnDefs, http://datatables.net/examples/basic_init/hidden_columns.html )

  • flyingdogmdflyingdogmd Posts: 2Questions: 1Answers: 0

    Thank you so much for the quick response. I've fixed that but it doesn't appear to have fixed the problem. How's this look?

                var table = $('#test').DataTable({
                    dom: 'Rlfrtip',
                    "deferRender": true,
                    "processing": true,
                    "pagingType": "full_numbers",
                    "ajax": '@Url.Action("Action", "Controller")',
                    "columnDefs": [
                        {
                            "targets": [ 0 ],
                            "visible": false,
                            "searchable": false
                        }
                    ],
                    "columns": [
                        { "visible": false,
                          "data": "Column0" },
                        { "data": "Column1" },
                        { "data": "Column2" },
                        { "data": "Column3" },
                        { "data": "Column4.Name" },
                        { "data": "Column5.Name" },
                        { "data": "Column6.Name" }],
                    "order": [1, "desc"]
                });
    
  • julien07julien07 Posts: 1Questions: 0Answers: 0
    edited December 2014

    Hello,

    Thanks you for this amazing plugin.
    However, I am facing the same issue as flyingdogmd.

    I would like to hide the 1st column (id) but this is not working with the following code:

     table = $('#browse-table').DataTable(
                {
                    "processing": true,
                    "serverSide": true,
                    "stateSave": false,
                    "responsive":{
                        details: false
                    },
                    "dom": '<"top">rt<"bottom"ilp><"clear">',
                    "ajax": {
                        type: "GET",
                        "url": constants.host + "/api/place/datatable/",
                        "data": function (data)
                        {
                            data.userFilter =  settings.filterUser;
                            data.placeTypeFilter = settings.filterType;
                            data.listingFilter = settings.filterListing;
                            data.ratingFilter=settings.filterRating;
                            data.ratingMinFilter=settings.filterMinRating;
                            data.nameFilter=settings.filterName;
                            data.addressFilter=settings.filterAddress;
                            data.userId = settings.userProfile.id;
                        }
    
                    },
                    "columns": [
                        {"visible": false, "data": "id" },
                        { "data": "name" },
                        { "data": "address" },
                        { "data": "typeId" },
                        { "data": "rating" }
                    ],
                    "columnDefs": [
                        {
                            "targets": [ 0 ],
                            "visible": false,
                            "searchable": false
                        }]
    
    
    
                }
            );
    

    Any idea how to solve this issue ?

This discussion has been closed.