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

How to set a property dynamically using javascript on oTable

$
0
0
I have a page with many DataTable objects in it. They all have a class "testAbcd" associated with them.

I am able to get all these objects using document.getElementsByClassName("testAbcd").

I am then iterating over these objects and need to set the value of the attribute 'sPaginationType' dynamically based on some conditions.

How can I achieve this? i.e. set the value of an attribute on the DataTable object.

Thanks

Horizontal scrolling + ColVis issue

$
0
0
I've a table with content loaded via ajax with show-columns plugin.
live demo: http://tinyurl.com/bwbceb2

the headers cells are not aligned and if u try to show/hide columns or change their order the content overflows the table..
how can i solve this problem?

here is the snippet code about the table inizialitation:
$('#t1').dataTable({
"sAjaxSource": "array.txt",
"bDeferRender": true,
"sDom": 'C<"clear">lfrtip',
"sScrollX": "100%",
"sScrollXInner": "110%",
"bScrollCollapse": true});

maybe, by sDom, i can envelop the processing inside a div with overflow property setted up by css..could it work?

I mentioned this issue in another post, i'm sorry if this could be unfair but i really need urgent help!

Multiple type and data for Jeditable

$
0
0
Hi..
I'm confused about using column specific input type and data for a table.

Ex:
In classic approach we are using a code like this

type: select
data: "{'A':'A','B':'B','C':'C'}",

All I want is to define different types and also different data sources for different columns in one jeditable instance.

Like:
type: {'select input for 2nd column' ,'classic input for 5th column'}
data: {'data for 2nd column','data for 5th column'}

I hope I explained it clearly.

Thanks.

ColVis and server-side filtering

$
0
0
Is there a list of the columns which are currently displayed, managed by ColVis?

I'm trying to limit the server-side filtering clause by what columns are currently shown in the table. The standard params sent to the server don't seem to capture whether a column is hidden or not.

Code for Add/Moving rows

$
0
0
This isn't a plug-in, but some methods I wrote. The InsertDataTableRow method assumes that the data is a single array. More handling would be needed to handle other possibilities. Also, I am sure there is room for improvement. I am just curious what others think, and if they have suggestions. Thanks.

var GetDataTableObject = function (table) {
var $table = null;

if (typeof table == 'string') {
$table = $(table);
} else if (table instanceof $) {
$table = table;
} else {
$table = $(table);
}

if (!$.fn.DataTable.fnIsDataTable($table[0])) {
return null;
} else {
return $table.dataTable();
}
}

var InsertDataTableRow = function (table, data, newRowPos, sortColPos, sort) {
var result = false;
var $dataTable;

$dataTable = GetDataTableObject(table);
if ($dataTable == null) {
return;
}

var numRows = $dataTable.fnSettings().fnRecordsTotal();

if (newRowPos == null || newRowPos < 0) {
data[sortColPos] = numRows;
$dataTable.fnAddData(data, true);
} else {
var currentRow;
for (var i = 0; i < numRows; i++) {
currentRow = $dataTable.fnGetData(i);
if (currentRow[sortColPos] >= newRowPos) {
$dataTable.fnUpdate(parseInt(currentRow[sortColPos],10) + 1, i, sortColPos, false, false);
}
}
data[sortColPos] = newRowPos;
$dataTable.fnAddData(data, true);
}

if ($dataTable.fnSettings().fnRecordsTotal() > numRows) {
result = true;
}

if (result && sort) {
$dataTable.fnSort([[sortColPos, 'asc']]);
}

return result;
}

var MoveDataTableRow = function (sourceTable, targetTable, row, position) {
var insertResult = false;
var $sourceDataTable;
var $targetDataTable;
var $row;

$sourceDataTable = GetDataTableObject(sourceTable);
if ($sourceDataTable == null) {
return;
}
$targetDataTable = GetDataTableObject(targetTable);
if ($targetDataTable == null) {
return;
}

if (typeof row == 'string') {
$row = $(row);
} else if (row instanceof $) {
$row = row;
} else {
$row = $(row);
}

var data = $sourceDataTable.fnGetData(row[0]);
*** Note that the 0 is a hard coded sequence column position based on my implementation.
insertResult = InsertDataTableRow($targetDataTable, data, position, 0, true);
var deletedRow = $sourceDataTable.fnDeleteRow($row[0]);

return (insertResult && deletedRow != null && deletedRow.length != 0);
}

Use datatables for "big" proyect admin backend

$
0
0
Hi guys, i am spanish, sorry if my english isnt good.

Well, i am developing an online shop web application with PHP. I am right now with the backend, the private side where u can administrate the shop.

I started study datatables 1 week ago or something like that. It looks great.

I have something in mind, develop a big part of administration modules with datatables. This is inserts, edits, deletes, pagination, filters, ordering, hide/show ... for all "modules" ( shop sections, products, invoices, clients, users, roles, ...)

So i want to know if this can be made with datatables not hard way, i mean, dont having to be very pro with datatables because i am relatively new.

I am going to use server-side proccessing.
My targets are build an aplication where admin can administrate roles ( create, edit, .., access to data ).
Access to data means for example,
that a specific user only can see some diferents columns data from a specific module.
or that a specific user can see some columns on the interface but not be able to edit them.

I know how to store and take the role/user/resources info on data base ( DB ).

What I want to know if it is possible create a server-side php code to create a Json with all the info needed to load data on datatables depending from user privileges; the order,pagination,filters he choosed; ... and i want to know if isnt hard.

I hope have explained well.

I have doubts about what minimum html code i must create.
<table id="example" class="display">
              <thead>
                <tr>
                  <th></th>
                  <th></th>
                  <th></th>
                  <th></th>
                  <th></th>
                </tr>
              </thead>
              <tbody>
                <tr>
                </tr>
              </tbody>
            </table>
how do i create Json to send column tittles.
I am trying with
...
array_push($datosSalida["aaData"], array("Tasman", "Internet Explorer 4.5", "Mac OS 8-9", "-", "X"));
$datosSalida["aoColumns"] = array ();
      array_push( $datosSalida["aoColumns"], array(
          array( "sTitle" => "Engine" ),
          array( "sTitle" => "Browser" ),
          array( "sTitle" => "Platform" ),
          array( "sTitle" => "Version" ),
          array( "sTitle" => "Grade" ))
      );
      array_push( $datosSalida["aoColumns"], array(
          array( "mData" => "engine" ),
          array( "mData" => "browser" ),
          array( "mData" => "platform" ),
          array( "mData" => "version" ),
          array( "mData" => "grade" ))
      );
      echo json_encode( $datosSalida );

TableTools - Exporting Buttons not working, Print Works. See Details Inside...

$
0
0
So I've been crawling these boards and a bunch of blogs and even stackoverflow trying to find a solution to this issue.

I have TableTools in my DataTable. This is my Tables' init...
$("#resultTable").dataTable({
	"bFilter": true,
	"bJQueryUI": true,
	"bPaginate": true,
	"bProcessing": true,
	"iDisplayLength" : 20,
	"sAjaxSource": "scripts/PHP/responses/" + file,
	"sDom": 'T<"clear">lfrtip',
	"oTableTools": {
		"sSwfPath": "scripts/JS/DataTables-1.9.4/extras/TableTools/media/swf/copy_csv_xls_pdf.swf"
	},
	"sPaginationType": "full_numbers",
	"aoColumns": dtCols
});
var ttInstances = TableTools.fnGetMasters();
for (var j in ttInstances) {
	ttInstances[j].fnResizeButtons();
}

I'm using the normal CSS/JS files for TableTools/ZeroClipboard/DataTables.

The toolbar loads, but it's not quite in the right spot. Copying the init data of 'T<"clear">lfrtip' I would expect (like the sample) that this would go above the search bar, my toolbar is off to the right of the search bar. NONE of the buttons 'hover' EXCEPT for the Print button. All of the buttons are slightly overlapped when bJQueryUI is true, if I set this to false the buttons look perfect, but still have no use of any button but Print.

If I omit the sSwfPath it also loads just fine, but buttons do not work.

I cannot easily post a working example, however if this becomes critical I'll arrange something.

This is not a local 'file://' issue. This is not a flash error. There are no JS errors in my console. I have tried everything from setting the TableTools.DEFAULTS fixes, to fnResizeButtons(). Any assistance you can provide will be helpful. Thank you!

Other notes:
- This is loading from an ajax source
- The table lives in a dialog()
- Table has class of 'display'
- Have tried using JUI/themeroller CSS's. I have tried the latest TableTools and also TableTools that comes with DT.

Thanks!!

Creating custom add/edit/remove function

$
0
0
Hey all,

So im trying to add add/edit/remove functionality to my table. but am rather confused on how to do it so far. I need to have them make a call to another method which then sends the SQL command to our MS SQL server to change the database. So far i see that using the
 "aButtons": [ "Add", "Edit", "Delete" ] 
creates the buttons, but im not clear on how to define their functions. id like them to call to one of my classes which has the SQL command in it, and pass the data in which the method then sends and processes. Is there a way to do this? or do i have to make a php file and do the individual SQL commands nested in that somehow?

Thanks!

Is there a tutorial on using JQuery DataTable with MVC3?

$
0
0
I'm fairly new and I've found general tutorials but nothing detailed enough for a beginner. I have a table in Mvc and would like to convert it into a datatable. Please help.

Thanks

Datatable : problem with get all selected checkbox even it is filter

$
0
0
Hello,
First, I want to said sorry for my english.
Second, I have one prolem with using checkbox on datatable, and need help.
The problem is like this:
- Assume that I have 100 rows in table and I have a checkBox in each rows.
- I have one checkbox for select all checkbox when I click it.
when I click select all the checkBox, i do selected all checkbox in row of table and then when I click submit button I can get all the selected checkbox. It is good.
- But If I click select all the checkbox, all the checkbox in row of table is selected and then I try filter on the search text box, I got only 10 rows and every checkbox is still selected, and the problem when I click submit button, I still get all the selected checkBox(100 of checkbox). what I want is I want to get selected checkbox that I had filter.



Thank you
Chamnan

search function not working (server side processing)

$
0
0
Hi,

I've implemented a PHP/mysqli server side solution that is working almost perfectly fine. The only thing, for now, that isn't working is the search box.

I've taken the code from there -> http://datatables.net/development/server-side/php_mysqli

I've also searched in the forums here and found some potential solutions/workaround yet none were really what I was looking for.

Here's the 2 JSON response I'm getting

#1 When table is first generated
{
    "sEcho": 2,
    "iTotalRecords": "19",
    "iTotalDisplayRecords": "16",
    "aaData": [
        [
            "2012-12-18 12:18:21",
            "TypeC",
            "123123",
            "321321 ..00",
            "<button icon=\"ui-icon-pencil2\" onclick=\"resetEditBox()\">Edit</button>"
        ],
        [
            "2012-12-18 12:14:04",
            "TypeC",
            "555888",
            "987654321",
            "<button icon=\"ui-icon-pencil2\" onclick=\"resetEditBox()\">Edit</button>"
        ],
        [
            "2012-12-06 13:10:05",
            "TypeA",
            "222222",
            "222222",
            "<button icon=\"ui-icon-pencil2\" onclick=\"resetEditBox()\">Edit</button>"
        ],
        [
            "2012-12-06 13:08:32",
            "TypeA",
            "111111",
            "111111",
            "<button icon=\"ui-icon-pencil2\" onclick=\"resetEditBox()\">Edit</button>"
        ],
        [
            "2012-12-06 13:07:25",
            "TypeA",
            "789789",
            "789789",
            "<button icon=\"ui-icon-pencil2\" onclick=\"resetEditBox()\">Edit</button>"
        ],
        [
            "2012-12-06 13:03:09",
            "TypeA",
            "456456",
            "456456",
            "<button icon=\"ui-icon-pencil2\" onclick=\"resetEditBox()\">Edit</button>"
        ],
        [
            "2012-12-06 13:02:09",
            "TypeA",
            "123123",
            "123123",
            "<button icon=\"ui-icon-pencil2\" onclick=\"resetEditBox()\">Edit</button>"
        ],
        [
            "2012-11-30 11:47:25",
            "TypeA",
            "345345345",
            "345345345345",
            "<button icon=\"ui-icon-pencil2\" onclick=\"resetEditBox()\">Edit</button>"
        ],
        [
            "2012-11-29 17:58:12",
            "TypeA",
            "555555",
            "guillaume",
            "<button icon=\"ui-icon-pencil2\" onclick=\"resetEditBox()\">Edit</button>"
        ],
        [
            "2012-11-29 14:24:33",
            "TypeC",
            "654654",
            "jkghlk jhkl",
            "<button icon=\"ui-icon-pencil2\" onclick=\"resetEditBox()\">Edit</button>"
        ],
        [
            "2012-11-29 14:04:55",
            "tres",
            "5555555",
            "hey",
            "<button icon=\"ui-icon-pencil2\" onclick=\"resetEditBox()\">Edit</button>"
        ],
        [
            "2012-11-28 14:34:39",
            "TypeD",
            "9854542",
            "qwerty",
            "<button icon=\"ui-icon-pencil2\" onclick=\"resetEditBox()\">Edit</button>"
        ],
        [
            "2012-11-27 14:55:25",
            "TypeC",
            "456456",
            "I can more than likely write a big comment. I wonder how long can I go.",
            "<button icon=\"ui-icon-pencil2\" onclick=\"resetEditBox()\">Edit</button>"
        ],
        [
            "2012-11-27 14:54:23",
            "TypeD",
            "951753",
            "c'est un autre commentaire",
            "<button icon=\"ui-icon-pencil2\" onclick=\"resetEditBox()\">Edit</button>"
        ],
        [
            "2012-11-12 15:16:27",
            "TypeA",
            "123456",
            "This is a test comment 123123",
            "<button icon=\"ui-icon-pencil2\" onclick=\"resetEditBox()\">Edit</button>"
        ],
        [
            "2012-11-05 15:22:37",
            "TypeC",
            "654321",
            "This is another comment",
            "<button icon=\"ui-icon-pencil2\" onclick=\"resetEditBox()\">Edit</button>"
        ]
    ]
}

and #2, when I get the error (please note that the error appears the minute I type 1 character in the search box):
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(`created_date` LIKE '%t%' OR `name` LIKE '%t%' OR `reference` LIKE '%t%' OR `co' at line 2

From my investigation, it appears that the code generating the error is the following:
/**
 * Filtering
 * NOTE this does not match the built-in DataTables filtering which does it
 * word by word on any field. It's possible to do here, but concerned about efficiency
 * on very large tables, and MySQL's regex functionality is very limited
 */
$iColumnCount = count($aColumns);
 
if ( isset($input['sSearch']) && $input['sSearch'] != "" ) {
    $aFilteringRules = array();
    for ( $i=0 ; $i<$iColumnCount ; $i++ ) {
        if ( isset($input['bSearchable_'.$i]) && $input['bSearchable_'.$i] == 'true' ) {
            $aFilteringRules[] = "`".$aColumns[$i]."` LIKE '%".$db->real_escape_string( $input['sSearch'] )."%'";
        }
    }
    if (!empty($aFilteringRules)) {
        $aFilteringRules = array('('.implode(" OR ", $aFilteringRules).')');
    }
}

Any hints or help that would help me resolve this will be greatly appreciated. Let me know if there is any more information I can provide to help with this matter.

Cheers

fnServerData,bServerSide and sAjaxDataProp

$
0
0
Hi there,

I'm trying to use fnServerData to get around the cross-site scripting stuff, but dataTables is staying in 'processing' mode forever when I add it. FYI, bServerSide is set to false and sAjaxDataProp is set to empty. I can see that the API is being called properly, data is retrieved and fnCallback is even called, but there is something I am missing... Any help would be appreciated.

				$('#table_sites').dataTable( {
					"sDom": "<'row-fluid'<'span4'l><'span4'T><'span4'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
					"bProcessing": true,
					"sAjaxSource": 'http://mysite/api/site/list',
					"sAjaxDataProp": "",
					"fnCreatedRow": function( nRow, aData, iDataIndex ) {
						$(nRow).attr('id',aData["_id"])		//need this because server side data does not include DT_RowId
					},
					"fnServerData": function( sUrl, aoData, fnCallback, oSettings ) {
						oSettings.jqXHR = $.ajax( {
							"url": sUrl,
							"data": aoData,
							"success": fnCallback,
							"dataType": "jsonp",
							"cache": false
						} );
					}
				} );


returned from server :
[{"_id":"ID:50d214c23b8e77804000000d","name":"patati142","type":"general","version":"1.0","theme":"valencia-dark","created":1355945154,"modified":1355945154,"lang":"en-CA"},{"_id":"ID:50d214b83b8e77ac4100000a","name":"patati16","type":"general","version":"1.0","theme":"valencia-gray-black","created":1355945144,"modified":1355945144,"lang":"en-CA"},{"_id":"ID:50d212e73b8e77824000000c","name":"patati14","type":"general","version":"1.0","theme":"client-eiffelv2","created":1355944678,"modified":1355944704,"lang":"en-CA"},{"_id":"ID:50d2123e3b8e774b40000006","name":"patati13","type":"general","version":"1.0","theme":"client-ambassadeur","created":1355944509,"modified":1355944517,"lang":"fr-CA"},{"_id":"ID:50d2120d3b8e777e40000009","name":"patati12","type":"general","version":"1.0","theme":"client-createursaveurs","created":1355944460,"modified":1355944508,"lang":"fr-CA"}]

DataTables events unbound when using jquery split plugin

$
0
0
Hello,

I am using the jquery split plugin which basically display a DataTables table on the main side and an html textarea on the flip side.
When I go from the flip side to the heads side ( = showing the datatable), all datatables events are just gone unbound including search events, filter events, pagination events, etc... I don't know why this happen and how to solve this. I've tried to destroy the table and recreate it with fnDestroy or just refresh the table with fnAjaxReload which works ok but only that the events do not get bound.

Here is the code:

var self = this;
$('.flipButton').bind("click",function(){
		var elem = $(".myDatatableDiv");
		if(elem.data('flipped'))
		{
			elem.revertFlip();
			elem.data('flipped',false);
                                               //here I've tried self.datatable.fnDestroy();
                                               // then self.datatable.dataTable();
                                               // even self.datatable.fnAjaxReload(); but none worked
                                               self.datatable.dataTable();

 
		}
		else
		{
			elem.flip({
				direction:'lr',
				speed: 350,
				onBefore: function(){				
					elem.html(elem.siblings('.myTextArea').html());
				},
				color:'white'
			});
			elem.data('flipped',true);
		}
	});

Thanks for any tips,
Jimmy

The Dreaded 18 Column Table

$
0
0
Hey Guys,

I've been using DataTables and loving it. Of course I have someone who "needs" a table with 18 or so columns of data. About eight of them are date fields, and all the columns need to be sortable. There are other dropdowns as well which are planned to be filters for rendering the data.

In your experience, what do you guys do when faced with too much data to realistically display on a page? Color coding, popovers, drilldown, etc are viable options .. I just can't see needing to display 8 columns of dates, other than the fact they are needed for the sorting ability. Just wanting to see what everyone else thinks.

Thanks!

Saving and loading state on demande

$
0
0
I need to save state and load it back on demande.

For example: The user is satisfied with his column layout, filters and sorting and then decide to give a name to this state and save it. Now he needs to be able to bring this state anytime he wants or create others.

Is there a way to do that with dataTables?

Custom type with Ajax in IE7/IE8

$
0
0
I'm going to take a stab in the dark here and hope that you see some glaring idiot mistake in my code that would make this work perfectly in Chrome and FF, but not in IE7/IE8. I created a custom type for the Editor that generates a select2 dropdown that fetches data via AJAX. This control works perfectly in Chrome and FF. In IE7/IE8, the control renders and appears like it's going to function, but typing in the box has no effect...it doesn't attempt to perform the AJAX query. If you have any clues based on the code below, please let me know...otherwise I'll move on. Thanks!

// Our custom field type
$.fn.DataTable.Editor.fieldTypes.client = $.extend(true, {}, $.fn.DataTable.Editor.models.fieldType, {
    'create': function (conf) {
        var that = this;

        conf._enabled = true;

        // Create the elements to use for the input
        conf._input = $(
            '<input type="hidden" class="input-xlarge" />'
        )[0];

        setTimeout(function () {
            $(conf._input).select2({
                placeholder: 'Select a Client',
                minimumInputLength: 3,
                id: function (e) {
                    return e.ClientId;
                },
                ajax: {
                    url: '/ClientSearch',
                    dataType: 'json',
                    data: function (term, page) {
                        return { query: term };
                    },
                    results: function (data, page) {
                        return { results: data };
                    }
                },
                formatResult: function (client) {
                    return client.ClientName;
                },
                formatSelection: function (client) {
                    return client.ClientName;
                },
                initSelection: function (element, callback) {
                    return $.get('/ClientLookup', { query: element.val() }, function (data) {
                        callback(data);
                    });
                }
            });
        }, 250);

        return conf._input;
    },

    'get': function (conf) {
        return $(conf._input).val();
    },

    'set': function (conf, val) {
        if (!conf._enabled) {
            return;
        }

        $(conf._input).val(val).trigger('change');
    },

    'enable': function (conf) {
        conf._enabled = true;
        $(conf._input).removeClass('disabled');
    },

    'disable': function (conf) {
        conf._enabled = false;
        $(conf._input).addClass('disabled');
    }
});

The /ClientSearch url returns an array of JSON objects like this

[{"ClientId":"00857001","EnterpriseId":null,"ClientName":"00857001 - VSP Vision Benefits","ContractState":null,"Region":null,"ContractType":null,"ClientType":null,"GroupType":null,"BenefitOffering":null,"Population":null,"Sic":null,"SicCode":null,"UnderwritingCategory":null,"EffectiveDate":"\/Date(-62135568000000)\/","RenewalDate":"\/Date(-62135568000000)\/","TerminationDate":"\/Date(-62135568000000)\/","Benefits":null,"BenefitList":null,"AdminDivisions":null,"BillDivisions":null,"RenewalRep":null,"ServiceRep":null,"CorporateAccountManager":null,"RegionalAccountManager":null,"GroupServiceAdmin":null,"MembershipAdmin":null,"SalesAdmin":null,"ReportPeriod":null,"Members":0,"Claims":0,"ClaimsAmount":0,"AverageClaimsAmount":0,"MemberChange":false,"Enterprise":false,"PerformanceStandards":false,"Healthplan":false,"Medicare":false}]

The /ClientLookup url returns a single JSON object (just no [ ] around it)

{"ClientId":"00857001","EnterpriseId":null,"ClientName":"00857001 - VSP Vision Benefits","ContractState":null,"Region":null,"ContractType":null,"ClientType":null,"GroupType":null,"BenefitOffering":null,"Population":null,"Sic":null,"SicCode":null,"UnderwritingCategory":null,"EffectiveDate":"\/Date(-62135568000000)\/","RenewalDate":"\/Date(-62135568000000)\/","TerminationDate":"\/Date(-62135568000000)\/","Benefits":null,"BenefitList":null,"AdminDivisions":null,"BillDivisions":null,"RenewalRep":null,"ServiceRep":null,"CorporateAccountManager":null,"RegionalAccountManager":null,"GroupServiceAdmin":null,"MembershipAdmin":null,"SalesAdmin":null,"ReportPeriod":null,"Members":0,"Claims":0,"ClaimsAmount":0,"AverageClaimsAmount":0,"MemberChange":false,"Enterprise":false,"PerformanceStandards":false,"Healthplan":false,"Medicare":false}

I have 3 custom type controls similar to this, all that work in Chrome and FF, none that work in IE7/IE8. I haven't been able to try IE9 until this gets pushed out to the production server.

Any ideas would be greatly appreciated.

row details : fnOpen or fnAddData

$
0
0
Hi

sorry, i've not been very lucky using datatables live tool, but this is the link i can propose :
http://live.datatables.net/emayev/2/edit

all js is in the html part

So I'm new to datatables

What I do now :
I build a classic DOM table. I fill my cells with 'y' and 'n' values. Then with mRender, I replace these values with icons for each columns. This works good and is pretty fast.

This table shows rights on a given folder. User's rights are the result of the sum of rights that one user gets from its own rights and from the groups he belongs to.

Now I would to show some details about users, when clicking on the plus at the left of the row.
By now, I've based my script on the example given on datatables site :
http://www.datatables.net/release-datatables/examples/api/row_details.html

So my script works nearly the same way. The difference is that I get content from an ajax request. You can click on the plus on the live link, it will work but ajax request will fail, with no content.

The content I get from an ajax request looks like this :

<tr class="grouplist">
				<td>
				<span class="ui-widget gr-item">
					ind_id_1067
				</span>
				</td>
			<td id="~copie">n</td><td id="~courrier">y</td><td id="~d�placement">n</td><td id="~download">n</td><td id="~modification attributs">n</td><td id="~s�lection/panier">y</td><td id="~suppression">n</td><td id="~upload">n</td><td id="~visualisation attributs">y</td></tr>

What I would like to do is just to show the details in the same way I show main rows of the table. I have same switch values (y/n) at exactly the same place. I would just render new rows with italic and maybe a smaller police size for the first column.

How can I do that ? Should I use fnOpen or fnAddData ?

Can someone give me some clues please ? I don't know where to go.

And I'm not sure fnAddData will let me add rows at place I would like, just like fnOpen.
With fnOpen it creates a new table that I need to format just like the main one, and it looks hard to do it after ajax load.

What I need to do is add/remove some rows at the place just below the chosen row, with same rendering process that happens on the main table.

Thanks in advance for your help

Regards

Fred

Highlighting currently selected row but keeping it highlighted while on context menu

$
0
0
Hello,

I have highlighted rows in my jQuery datatable using the CSS technique described at the following page
http://datatables.net/release-datatables/examples/advanced_init/highlight.html which works very well.
I have then integrated the jQuery context menu plugin which works ok as well only that the highlighted row just goes un-highlighted as soon as the mouse cursor loses the focus off the row (while browsing the context menu). I would like the css-highlighted row to remain highlighted on the selected row as long as the mouse cursor browses the context menu. How could this be done?
Is css highlighting out of control by jQuery?
If so is there any other alternative to highlighting rows with datatables? I believe that this is a very natural effect that the row must remain highlighted as long as the context menu is being displayed.

Thanks in advance,
Jimmy

Bind the columns from server and pass some data to server in request

$
0
0
Hi

I am trying to use this plugin in serverside process. So far I m able to bind the serverdata as ajax source and works fine with table data.

But I would like to bind the columns also dynamically and pass aoData to server with request and not sure how.

I have seen some post and implemented as below.

<style type="text/css" title="currentStyle">
@import "Styles/demo_page.css";
@import "Styles/demo_table.css";
</style>

<script type="text/javascript" language="javascript" src="JavaScripts/jquery.js"></script>
<script src="JavaScripts/jquery.dataTables.js" type="text/javascript"></script>

<script type="text/javascript" charset="utf-8">

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

$.ajax({
"dataType": 'text',
"type": "GET",
"url": "test.txt",
"success": function(dataStr) {

var data = dataStr.replace("<jasoncontent>", "");
data = data.replace("</jasoncontent>", "");

data = JSON.parse(data);

$('#tblReport').dataTable({
"aaData": data.aaData,
"aoColumns": data.aoColumns
});
}
});
});



</script>


</head>
<body id="dt_example">

<form id="form1" runat="server">
<div id="container">
<div id="demo">

<table id="tblReport" class="display">

<tbody>

</tbody>
</table>

</div></div>
</form>

</body>
</html>

This code displays the table correctly. But how can get and pass the aoData[] through the request since the datatable initialized after the get request.

Do I need to make request twice not sure. Please share any sample code.

thanks in advance.

Problem with MVC3 and DataTable

$
0
0
Hi all.

I have a problem with DataTables integration to MVC3 project. Over 7 hours I'm trying to fix this problem, but it's beyond my power :)

But at once a've had good result: when I created new View without masterpage and put directly to header all the jquery.dataTables.min.js file code, but when I tried to repeat this trick at the layout page header - it didn't work. So I'm out and ask you for help.

Now I'll try to explain how i did that.

Here is my Layout's page header:

<head>
        <meta charset="utf-8" />
        <title>Example</title>
        <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
        <meta name="viewport" content="width=device-width" />
        @Styles.Render("~/Content/themes/base/css", "~/Content/css")
        @Scripts.Render("~/bundles/modernizr")
        <script type="text/JavaScript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
        <script type="text/JavaScript" charset="utf8" src="../Scripts/jquery.dataTables.min.js"></script>
        <script type="text/JavaScript" src="../Scripts/scripts.js"></script>
    </head>

And here is table building:
<table id="campaigns-table">
	<thead>
		<tr class="manage-campaigns-webgrid-header">
			<th id="campaign-name">Name</th>
			<th id="campaign-min-price"><img src="../Images/min-price.png" alt="Minimal price per minute(cents)" title="Minimal price per minute(cents)" height="20px"></th>
			<th id="campaign-max-price"><img src="../Images/max-price.png" alt="Maximal price per minute(cents)" title="Maximal price per minute(cents)" height="20px"></th>
			<th id="campaign-budget"><img src="../Images/budget.png" alt="Max budget per order" title="Max budget per order" height="20px"></th>
			<th id="campaign-orders">Orders</th>
			<th id="campaign-status">Status</th>
			<th id="campaign-delete">Delete</th>
		</tr>
	</thead>
	<tbody>
	
		@{
			foreach (var c in ViewBag.CampaignsList)
            {
			    <tr class="table-short-info">
                    <td>@Html.ActionLink((string)c.CampaignName, "EditCampaign", controllerName: "Campaign", routeValues: new { cid = c.CampaignId }, htmlAttributes: null)</td>
                    <td>@c.CampaignMinPrice.ToString("F")</td>
                    <td>@c.CampaignMaxPrice.ToString("F")</td>
                    <td>@c.CampaignMaxBudget.ToString("F")</td>
                    <td>
                        @Html.ActionLink((string)c.CampaignOrdersCount, "ManageOrders", controllerName: "Order", routeValues: new { cid = c.CampaignId }, htmlAttributes: null)
                        (@Html.ActionLink((string)c.CampaignOpenOrdersCount, "ManageOrders", controllerName: "Order", routeValues: new { cid = c.CampaignId, status = "open" }, htmlAttributes: null)|
                        @Html.ActionLink((string)c.CampaignClosedOrdersCount, "ManageOrders", controllerName: "Order", routeValues: new { cid = c.CampaignId, status = "closed" }, htmlAttributes: null))
                    </td>
                    <td>
                        <a href="@Url.Action(actionName: "ChangeCampaignStatus", controllerName: "Campaign", routeValues: new { cid = c.CampaignId, status = "open" })"><img src="~/Images/open-campaign.png" alt="Open campaign" title="Open campaign" height="16px" class="open-campaign-button" /></a>
                        <a href="@Url.Action(actionName: "ChangeCampaignStatus", controllerName: "Campaign", routeValues: new { cid = c.CampaignId, status = "closed" })"><img src="~/Images/close-campaign.png" alt="Close campaign" title="Close campaign" height="16px" class="close-campaign-button" /></a>
                    </td>
                    <td>@Html.ActionLink("Delete", "DeleteCampaign", new { cid = c.CampaignId })</td>
			    </tr>
            }
		}
		
	</tbody>
</table>

And script-file:

$(document).ready(function () {
    $("#campaigns-table").dataTable();
});

Look forward to your help.
Viewing all 82217 articles
Browse latest View live


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