rowCallback not working with rowGroup

rowCallback not working with rowGroup

zgoforthzgoforth Posts: 493Questions: 98Answers: 2

Link to test case: https://jsfiddle.net/BeerusDev/phncg5t7/111/

Hello, as you can see in my example, rowCallback is working to hide rows on every table, but when I have a table that uses rowGroup.startRender, it doesn't effect that table, and still shows the No Group row...

Answers

  • zgoforthzgoforth Posts: 493Questions: 98Answers: 2

    I tried the following: https://datatables.net/reference/option/rowGroup.emptyDataGroup, which states

    If null is given as the value, no grouping row will be shown (since 1.0.3).

    but it still shows a rowgroup with "null" and is now no longer collapsible/expandable

  • kthorngrenkthorngren Posts: 21,322Questions: 26Answers: 4,948
    edited September 2021

    Datatables doesn't know about the hidden row when you manipulate the table outside of Datatables APIs. Using $(row).hide(); won't work with Datatables as Datatables still has that row marked as displayed. Create a search plugin to filter the rows.

    Kevin

  • zgoforthzgoforth Posts: 493Questions: 98Answers: 2

    https://jsfiddle.net/BeerusDev/phncg5t7/129/,

    I added on to my current searchPlugin for each table, and it is supposed to hide the Cletus Dev item in table 3&4 but it is still showing it...

          if ( settings.sTableId === 'myTable3' ) {
            if(phoneCheck === null){
              return false;
            } else {
              return true;
            }
    
          }
         if ( settings.sTableId === 'myTable4' ) {
            if(monthCheck === null){
              return false;
            } else {
              return true;
            }
    
          }
    
  • zgoforthzgoforth Posts: 493Questions: 98Answers: 2

    Here is my updated JSFiddle: https://jsfiddle.net/BeerusDev/phncg5t7/152/

    I have been trying and trying, the condition makes sense, it just is not accepting it and still showing the blank value.. Why is this, I ended up changing it to the following:

    $.fn.dataTable.ext.search.push(
        function( settings,searchData, data, dataIndex ) {
        var bdayBool = searchData[2];
        var hireBool = searchData[2];
        var phoneCheck = searchData[1];
        var extCheck = searchData[2];
        var monthCheck = searchData[2];
        
            
        if ( settings.sTableId === 'myTable1' ) {
          if(bdayBool === "Yes"){
          return true;
          } else {
            return false;
         }
         }
         if ( settings.sTableId === 'myTable2' ) {
            if(hireBool === "Yes"){
              return true;
            } else {
              return false;
            }
    
          }
          if ( settings.sTableId === 'myTable3' ) {
            if(phoneCheck != null){
              return true;
            } else {
              return false;
            }
    
          }
         if ( settings.sTableId === 'myTable4' ) {
            if(monthCheck != null){
              return true;
            } else {
              return false;
            }
    
          }
    
    
          return true;
    
    });
    
  • kthorngrenkthorngren Posts: 21,322Questions: 26Answers: 4,948

    Have you debugged the values of phoneCheck and monthCheck? Could be they are empty strings. Check for both null and empty string ("").

    Kevin

  • zgoforthzgoforth Posts: 493Questions: 98Answers: 2
    edited September 2021

    Well in my JSFiddle, the array of objects I defined as data for Javscript sourced data, is as follows:

    var data = [
    {
        "Name": "Beerus Dev",
      "Birthday": "9/07/2021",
      "BirthdayThisMonth": "Yes",
      "BirthMonth":"September",
      "HireDate": "9/16/2021",
      "HireDateThisMonth": "Yes",
      "YearsWorkedHere": "2.0000",
      "Phone": "XXX-XXX-XXXX",
      "Extension": "ext#"
    },
    {
      "Name": "Cletus Dev",
      "Birthday": null,
      "BirthdayThisMonth": null,
      "BirthMonth": null,
      "HireDate": null,
      "HireDateThisMonth": null,
      "YearsWorkedHere": null,
      "Phone": null,
      "Extension": null
    }
    ];
    

    The value I expected was to be null or even undefined, but apparently it is returning " " an empty string, I made some adjustments and it is good to go

Sign In or Register to comment.