Skip to content

Angularjs plugin smart table st-search through random text entered like datatablejs search #835

@dhavebarsalote96636677

Description

@dhavebarsalote96636677

Hi, i have used this angular plugin and it works very well with massive rows of data (6K rows). But i noticed something that whenever I do search for items using st-search, it does not allow me to search through text, for example i have this item description: "BOSCH AQUATAK DIY HIGH PRESSURE WASHER AQT 33-11" and so i type to the input field "BOSCH WASHER". No data is displayed. What should I do to fix this. I have looked into the st-search directive:

ng.module('smart-table')
  .directive('stSearch', ['stConfig', '$timeout','$parse', function (stConfig, $timeout, $parse) {
    return {
      require: '^stTable',
      link: function (scope, element, attr, ctrl) {
        var tableCtrl = ctrl;
        var promise = null;
        var throttle = attr.stDelay || stConfig.search.delay;
        var event = attr.stInputEvent || stConfig.search.inputEvent;
        var trimSearch = attr.trimSearch || stConfig.search.trimSearch;

        attr.$observe('stSearch', function (newValue, oldValue) {
          var input = element[0].value;
          if (newValue !== oldValue && input) {
            ctrl.tableState().search = {};
            input = ng.isString(input) && trimSearch ? input.trim() : input;
            tableCtrl.search(input, newValue);
          }
        });

        //table state -> view
        scope.$watch(function () {
          return ctrl.tableState().search;
        }, function (newValue, oldValue) {
          var predicateExpression = attr.stSearch || '$';
          if (newValue.predicateObject && $parse(predicateExpression)(newValue.predicateObject) !== element[0].value) {
            element[0].value = $parse(predicateExpression)(newValue.predicateObject) || '';
          }
        }, true);

        // view -> table state
        element.bind(event, function (evt) {
          evt = evt.originalEvent || evt;
          if (promise !== null) {
            $timeout.cancel(promise);
          }

          promise = $timeout(function () {
            var input = evt.target.value;
            input = ng.isString(input) && trimSearch ? input.trim() : input;
            tableCtrl.search(input, attr.stSearch || '');
            promise = null;
          }, throttle);
        });
      }
    };
  }]);

how can I update this to have the below image results when i do searchl.

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions