unexpected no of td elements

unexpected no of td elements

28.vivek.s28.vivek.s Posts: 69Questions: 0Answers: 0
edited November 2010 in General
hi Allan,

i am getting an alert message i.e.
DataTables warning: Unexpected number of TD elements. Expected 8 and get 2.
while in my table there are 2 rows and 8 colomn.the first thing is why dataTable is not reading 2nd row and second thing is why its getting only 2 cells in first row,while it have 8 cells..here is my table structure.
[code]



ID and Description
Type
Format
VendorId
ReqNo
Date
Availability
Size






CW-MICROCONTROLLERS


IDE - Debug, Compile and Build Tools

-


html


-
-
5/24/2010

yes





CW MCU v6.2 PE Update v3.04


Updates & Patches

-
exe

199441


3.04


10/24/2008

-







[/code]

please help me out.
thanks in advance

regards
vivek

Replies

  • allanallan Posts: 63,400Questions: 1Answers: 10,452 Site admin
    I'd suggest running your page through he W3C Validator ( http://validator.w3.org/ ). There are a couple of little HTML hiccups there which it will pick up. If that doesn't fix it (and it should, because otherwise it looks fine!) then if you could post back with a link that would be great.

    Allan
  • 28.vivek.s28.vivek.s Posts: 69Questions: 0Answers: 0
    edited November 2010
    hi Allan,
    thanks for quick reply.i solved this issue.
    but i came up with another problem in filtering logic.
    suppose i passes abc in fnFilter(), then its giving me all data which starts from abc.
    how to fix it.
    please tell me.
    i tried by appending "^" before string something like "^"+abc and then passed it into fnFilter,
    but then i getting no matching records found.
    if you have already discussed this thing then please give me the URL of that discussion.

    thanks,
    vivek
  • allanallan Posts: 63,400Questions: 1Answers: 10,452 Site admin
    Disable smart filtering if you want to add regex characters of your own: http://datatables.net/api#fnFilter . Otherwise the smart filtering will interfere with it.

    Allan
  • 28.vivek.s28.vivek.s Posts: 69Questions: 0Answers: 0
    edited November 2010
    Hi Allan,
    i have already done that,but still i m getting same issue.
    here is my code
    [code]
    $(document).ready(function() {
    var oTable = jQuery('#CacheSearchResultsTable').dataTable();
    var linkLineData = document.getElementById("linkline").value;
    if((linkLineData=="Data Sheets" || linkLineData=="Application Notes") && linkLineData != undefined){
    linkLineData = "^"+linkLineData;
    oTable.fnFilter(linkLineData,1,false);
    }

    });
    [/code]

    Please let me know, where i am wrong.
    Thanks Vivek
  • allanallan Posts: 63,400Questions: 1Answers: 10,452 Site admin
    It looks like you've disabled regex, but left smart filtering on: http://datatables.net/api#fnFilter . The third parameter passed in as false is for regex.

    Allan
  • 28.vivek.s28.vivek.s Posts: 69Questions: 0Answers: 0
    edited November 2010
    i disabled smart filtering too, but still the problem remain same.
    i wonder whats going on,because the same thing i did with my other code and there it's working fine.
    i tried with this code too.
    [code]oTable.fnFilter(linkLineData,1,false,false);[/code]
    as you said,but still same issue-"no matching records found".

    I would like to remind you that i m using dataTable version 1.6.2.
    please help me out.

    thanks a lot for your quick response
    Vivek
  • allanallan Posts: 63,400Questions: 1Answers: 10,452 Site admin
    Right - DataTables 1.6 probably isn't going to help here as it doesn't provide the option to disable smart filtering (the API method has changed a bit). I'd suggest as the first thing to upgrade to 1.7.4. Then have a look at the documentation for fnFilter again - I thin you will want:

    [code]
    oTable.fnFilter(linkLineData,1,true,false);
    [/code]
    Note also that this will match at the start of the row only, since you are testing the entire row (and the strings are concatenated together with a double space separator). If you want to match the "start" of a string (i.e. a new cell) in the middle or a row, you'll need to take this into account as well.

    Allan
  • 28.vivek.s28.vivek.s Posts: 69Questions: 0Answers: 0
    edited November 2010
    ya, i think you right,but i did same thing 2 months back with same version i.e. 1.6.2.
    still i am trying,if will get any solution i will get back to you.
    here is my previous code....on click of a button i m calling this function.
    [code]
    function submitData(str,iColumn)
    {
    var container = "";
    jQuery("#"+str+" :checked").each(function() {
    if(container.length==0){
    container = "^"+jQuery(this).val().LTrim();
    container= fnEscapeRegex(container);
    }
    else{
    container += "|" +"^"+jQuery(this).val().LTrim();
    container= fnEscapeRegex ( container);
    }
    });
    if(container.length>0){
    oTable.fnFilter([container],iColumn,false);
    }
    else{
    oTable.fnFilter('',iColumn,false);
    }
    }
    [/code]

    This code is working properly.
    now,i can not upgrade version,because after couple of days code will pushed to production site.
    so, till then i have to stick with this version only.

    Vivek
  • 28.vivek.s28.vivek.s Posts: 69Questions: 0Answers: 0
    edited November 2010
    hi Allan,

    i solved this issue by appending this regular expression in string before passing it to fnFilter()...
    here is my code
    [code]
    function submitData(str,iColumn)
    {
    var container = "";
    jQuery("#"+str+" :checked").each(function() {
    if(container.length==0){
    container = "^\\s*"+jQuery(this).val().LTrim()+"\\s*$";
    container= fnEscapeRegex(container);
    }
    else{
    container += "|"+ "^\\s*"+jQuery(this).val().LTrim()+"\\s*$";
    container= fnEscapeRegex ( container);
    }
    });
    if(container.length>0){
    oTable.fnFilter([container],iColumn,false);
    }
    else{
    oTable.fnFilter('',iColumn,false);
    }
    }
    [/code]

    And it's working fine in all version of DataTable.
    Once again thanks for such a good plug-in.
    Thanks,
    Vivek
This discussion has been closed.