Filter Problem When Using render Function

Filter Problem When Using render Function

tlbaxter99tlbaxter99 Posts: 5Questions: 4Answers: 0
edited June 2016 in Free community support

I have a simple DataTable example where the filtering functionality seems not to work correctly when a column has a render function attached. I would like to describe the incorrect behavior but I have not found a pattern. It's just wrong. Removing the render function removes the problem.

I would like to be able to search on the results of the render function.

Below is the entire body element containing all relevant code:

<body>
   <div id="vitsContainer">

   </div>


   <script>
      "use strict";
      jQuery(document).ready(documentReady);

      var dataSet = [
         ["Inverse Dow 2x Strategy", "abc"],
         ["Series P (High Yield Series)", "xyz"]
      ];

      function documentReady() {
         var tableElement = document.createElement("table");
         tableElement.id = "tbl_Funds";

         $("#vitsContainer").append(tableElement);

         $("#" + tableElement.id).DataTable({
            "data": dataSet,
            "ordering": false,
            "paging": false,
            "bInfo": false,
            "columns": [
                { "title": "Fund", "orderable": false, "searchable": true },
                {
                   "title": "CUSIP", "orderable": false, "searchable": true,
                   "render": function () {
                      return generateRandomCusip();
                   }
                }
            ]
         });
      } // documentReady()

      function generateRandomCusip() {
         var validCharacters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";

         var cusip = "";

         for (var i = 0; i < 9; ++i) {
            var k = Math.random() * validCharacters.length;
            cusip += validCharacters.substring(k, k + 1);
         }

         return cusip;
      }
   </script>
</body>
This discussion has been closed.