Search
11430 results 8991-9000
Forum
- 17th Nov 2012DataTables individual column filtering example (multi_filter_select) with Server-side processingForgive me but I am a new user ... I would like to create a table of data coming from my external database mysql. So far, so good. My issue comes up in "select". This is my code: PAGE /1/ function fnCreateSelect( aData ){ var r=' Select... ', i, iLen=aData.length; for ( i=0 ; i<iLen ; i++ ) { r += ''+aData[i]+''; } return r+''; } /2/ (function($) { $.fn.dataTableExt.oApi.fnGetColumnData = function ( oSettings, iColumn, bUnique, bFiltered, bIgnoreEmpty ) { if ( typeof iColumn == "undefined" ) return new Array(); if ( typeof bUnique == "undefined" ) bUnique = true; if ( typeof bFiltered == "undefined" ) bFiltered = true; if ( typeof bIgnoreEmpty == "undefined" ) bIgnoreEmpty = true; var aiRows; if (bFiltered == true) aiRows = oSettings.aiDisplay; else aiRows = oSettings.aiDisplayMaster; var asResultData = new Array(); for (var i=0,c=aiRows.length; i<c; i++) { iRow = aiRows[i]; var aData = this.fnGetData(iRow); var sValue = aData[iColumn]; if (bIgnoreEmpty == true && sValue.length == 0) continue; else if (bUnique == true && jQuery.inArray(sValue, asResultData) > -1) continue; else asResultData.push(sValue); } return asResultData; } }(jQuery)); /3/ $(function() { $("#test").button().click(function() { /3.1/ var oTable= $('#userDataTable').dataTable( { "bProcessing": true, "bServerSide": true, "bJQueryUI": true, "sPaginationType": "full_numbers", "oLanguage": {"sSearch": "Cerca in tutte le colonne:"}, "sAjaxSource": "/php/userDataTable.php" }); /3.2/ $("tfoot th").each( function ( i ) { this.innerHTML = fnCreateSelect( oTable.fnGetColumnData(i) ); $('select', this).change( function () { oTable.fnFilter( $(this).val(), i ); } ); } ); $( "#testWindow" ).dialog( "open" ); }); $( "#testWindow" ).dialog({ autoOpen: false, width: 900,}); }); </script> </head> <body> <div id="Page" align="center"> <button id="test">Test</button><br /> </div> <div class="dialogCenter" id="testWindow" title="TEST WINDOW"> <table class="display" id="userDataTable"> <thead align="center"> <tr> <th>Surname</th> <th>Name</th> <th>Username</th> <th>Email</th> <th>Level</th> <th>Accesso</th> <th>Valid</th> <th>Active</th> </tr> </thead> <tbody> <tr class="gradeA"> <td class="dataTables_empty">Loading data from server</td> </tr> </tbody> <tfoot> <tr> <th></th> <th></th> <th></th> <th></th> <th></th> <th></th> <th></th> <th></th> </tfoot> </table> </div> </body> I suppose that the problem is out because the data is inserted after initializing the columns (up 3.1 part after the function 2). I tried to call the functions correctly, but I get an error (Uncaught TypeError: Object [object Object] has no method 'fnGetColumnData') .... I think that there is a syntax error .... The best thing would be to put it in a file esetrno (/ js / function.js). Can anyone help me??
- 8th Oct 2012Multiple search filteringI'm a bit of a newbie to datatables, and I couldn't find an answer to this question anywhere on the forums, maybe just not looking in the right places. I was wondering if I had two text inputs, whether I can do an OR style search through datatables, so instead of the text in both inputs needing to be both in the search result, that either of them can be in the results. Hope that makes sense. Thanks in advance.
- 19th Sep 2012Why is my DataTable headers not sorting and the fields not filtering?Reports First Name Last Name Grade Attendance Code Class Day Reports First Name Last Name Grade Attendance Code Class Day @foreach (var item in Model.Enrollments) { @Html.HiddenFor(modelItem => item.EnrollmentID) @Html.HiddenFor(modelItem => item.Assignment) @Html.HiddenFor(modelItem => item.Course.Title) @Html.HiddenFor(modelItem => item.CourseID) @Html.HiddenFor(modelItem => item.Date) @Html.HiddenFor(modelItem => item.dayOfWeek) @Html.HiddenFor(modelItem => item.Instructor) @Html.HiddenFor(modelItem => item.StudentID) @Html.HiddenFor(modelItem => item.Student.Address) @Html.HiddenFor(modelItem => item.Student.CourseID) @Html.HiddenFor(modelItem => item.Student.Courses) @Html.HiddenFor(modelItem => item.Student.EnrollmentDate) @Html.HiddenFor(modelItem => item.Student.Enrollments) @Html.HiddenFor(modelItem => item.Student.FullName) @Html.HiddenFor(modelItem => item.Student.InstructorID) @Html.HiddenFor(modelItem => item.Student.Instructors) @Html.HiddenFor(modelItem => item.Student.StudentID) @Html.ActionLink("Report", "PrintCustomers", "PdfRender", new { sName = item.Student.FirstMidName, courseTitle = item.Course.Title, sNumber = item.Student.StudentNum, instructorName = HttpContext.Current.Session["teacherName"] }, null) @Html.EditorFor(modelItem => item.Student.FirstMidName) @Html.EditorFor(modelItem => item.Student.LastName) @Html.TextBoxFor(modelItem => item.Grade, new { Value = "0" }) @Html.ValidationMessageFor(model => model.Enrollments.FirstOrDefault().Grade) @Html.TextBoxFor(modelItem => item.attendanceCode, new { Value = "1" }) @Html.ValidationMessageFor(model => model.Enrollments.FirstOrDefault().attendanceCode) @Html.EditorFor(modelItem => item.classDays) } <br /> <Input Type ="submit" Value="Submit Attendance"/> }
- 5th Sep 2012While filtering does not apply changes to the tableI am using fnRowCallback to highlight and make some modifications to the table. It works fine when I load the page, everything works as per the code. This is the following code I have [code] if(aData[17] != null) { $('td:eq(0)', nRow).html(" "); $(nRow).find('td:contains("edit")').html("edit"); $(nRow).css({'background-color':'#999999','color':'#E4E4E4', "cursor": "default"}); } [/code] When I enter text in the search field [code] $('td:eq(0)', nRow).html(" "); $(nRow).find('td:contains("edit")').html("edit"); [/code] do not seem to work. It would not replace the first column with the cancel icon, and also do not change the edit hyperlink to edit text. Is something wrong with my code or is there anything I am forgetting.
- 27th Aug 2012Column filtering on table headerHow can I change the default location of column filters to now be displayed on the table header?
- 17th Aug 2012Move default filters into existing divHi there! Just wondered if this was possible? Basically I want to have complete control over the position of the filtering elements so I can render them inside another div element on the page. Thanks
- 26th Jun 2012rowGrouping & footer column filtering working together?Has anyone been able to get rowGrouping plug-in to work with individual column filters in the footer? It seems the rowGrouping throws off the indexing. Anyone have a working example of them together?
- 9th Apr 2012Adding filtering function to a columnI have a table which have information which I would like to exclude from the search box. For example, in one of the columns I have some text and then links, it looks like that: [code] John Doe View | Edit | Delete [/code] Of-course in this case I would like the search box to consider only "John Doe" as a text to be searched. I draw my table in php (I use Symfony-2) and apply the DataTable plugin using dataTable function with jQuery. I got the impression that what I want is possible, but couldn't manage to achieve it. Other discussions like http://www.datatables.net/forums/discussion/255/customising-the-way-the-filter-works/p1 neither helped me to solve this problem. Thanks! Guy
- 2nd Apr 2012TableTools with filtersHi! How can I save the values I've entered in the input fields in the pdf document using the TableTools? Thanks!!
- 30th Mar 2012Adding Filters to a Datatable which has source from a php FileHey Buddy i have a trouble here.This is my code here. I want to do column based/cell based filtering.I have datasource from a php file.Where exactly should i pass the ajax_source ('sAjaxSource':'table_data.php') parameter?? Kindly help //HTML code ; @import " datatables/media/css/demo_table.css"; table{width:100%} < script> (function($) { $('#the_table').dataTable({ 'sAjaxSource':'table_data.php' }); /* * Function: fnGetColumnData * Purpose: Return an array of table values from a particular column. * Returns: array string: 1d data array * Inputs: object:oSettings - dataTable settings object. This is always the last argument past to the function * int:iColumn - the id of the column to extract the data from * bool:bUnique - optional - if set to false duplicated values are not filtered out * bool:bFiltered - optional - if set to false all the table data is used (not only the filtered) * bool:bIgnoreEmpty - optional - if set to false empty values are not filtered from the result array * Author: Benedikt Forchhammer <b.forchhammer /AT\ mind2.de> */ $.fn.dataTableExt.oApi.fnGetColumnData = function ( oSettings, iColumn, bUnique, bFiltered, bIgnoreEmpty ) { // check that we have a column id if ( typeof iColumn == "undefined" ) return new Array(); // by default we only wany unique data if ( typeof bUnique == "undefined" ) bUnique = true; // by default we do want to only look at filtered data if ( typeof bFiltered == "undefined" ) bFiltered = true; // by default we do not wany to include empty values if ( typeof bIgnoreEmpty == "undefined" ) bIgnoreEmpty = true; // list of rows which we're going to loop through var aiRows; // use only filtered rows if (bFiltered == true) aiRows = oSettings.aiDisplay; // use all rows else aiRows = oSettings.aiDisplayMaster; // all row numbers // set up data array var asResultData = new Array(); for (var i=0,c=aiRows.length; i<c; i++) { iRow = aiRows[i]; var aData = this.fnGetData(iRow); var sValue = aData[iColumn]; // ignore empty values? if (bIgnoreEmpty == true && sValue.length == 0) continue; // ignore unique values? else if (bUnique == true && jQuery.inArray(sValue, asResultData) > -1) continue; // else push the value onto the result data array else asResultData.push(sValue); } return asResultData; }}(jQuery)); function fnCreateSelect( aData ) { var r='', i, iLen=aData.length; for ( i=0 ; i<iLen ; i++ ) { r += ''+aData[i]+''; } return r+''; } $(document).ready(function() { /* Initialise the DataTable */ var oTable = $('#the_table').dataTable( { "oLanguage": { "sSearch": "Search all columns:" } } ); /* Add a select menu for each TH element in the table footer */ $("tfoot th").each( function ( i ) { this.innerHTML = fnCreateSelect( oTable.fnGetColumnData(i) ); $('select', this).change( function () { oTable.fnFilter( $(this).val(), i ); } ); } ); } ); BusNO BusType Departure Arrival Seats SeaterFare