Sorting the Filter Entities using the Remove Digits Prefix from Filter

Comments

10 comments

  • Avatar
    Malinda Jepsen

    Very cool.  I'll have to check this out!

    0
    Comment actions Permalink
  • Avatar
    Alon Ahronberg

    Thanks Chen,

     

    Another way to add the prefix number is using the rank function.
    There's a need sometimes to order the value in a descending way - and not manually adjust the numbers
     
    Example on creating the dim table:
     
    SELECT Category, tostring(r) + '.' + Category
    FROM (
    SELECT DISTINCT c.Category,rankdesc(c.Category) AS r
     
    from [category] c
     
    ) data
    0
    Comment actions Permalink
  • Avatar
    Michael Becker

    Hi,

     

    a very nice one! Just be careful with time dimensions, for me it converts all time filters to time stamps, no matter if you use month,days or years.

    0
    Comment actions Permalink
  • Avatar
    Sanjoy Ghosh

    Hi Michael,

    Even I'm facing the same issue where the time filters are converting to timestamps when using this plugin. Did you find any other solution to tackle it ?

     

    Regards,

    Sanjoy

    0
    Comment actions Permalink
  • Avatar
    Andrey Prostakov

    Careful with this plugin.

    Our "Search" tool on dashboard filters broke when we added it. Specifically, wrong results were being shown.

    Example: 
    When I search with key "CC" in a collection of "AA", "BB" and "CC", then I get "AA".
    When I hover it, tooltip says "CC".

    0
    Comment actions Permalink
  • Avatar
    Jessica Orlando

    Did anyone find a resolution to this plugin breaking date filters?

    0
    Comment actions Permalink
  • Avatar
    Michael Wozniak

    I just noticed the issue with date filters as well.  I am not the most familiar with Javascript but believe I have a half-baked solution.  The configuration asks you to specify the columns for which you want the prefix truncated.  However, the code only checks if a valid table, column, and value exist before doing anything.  Later, it checks whether the column is in your config before deciding whether to remove the first two spaces.  At this point it is too late, as the entire value will be converted to text and returned.  So, even if it is not one of the columns you wish to alter, it is still converted to text.  My solution is to alter the mod.directive('span' function to check if the column is in the list in the config before doing anything.  That way, if it is not specified the script will not convert it to text.  Open the main.js file and replace the "mod.directive('span'" section with: 

     

    mod.directive('span', [

    function () {
    return {

    transclude: false,
    restrict: 'E',
    link: function link($scope, lmnt, attrs) {
    if ($$get($scope,"$parent.$parent.in.table") && $$get($scope,"$parent.$parent.in.column")){
    if (shouldConvertField($scope.$parent.$parent.in.table,$scope.$parent.$parent.in.column)){
    var text = convertItem($scope.$parent.$parent.in.table,
    $scope.$parent.$parent.in.column,
    $scope.$parent.$parent.member);

    $(lmnt).text(text);
    setTimeout(function(){
    $(lmnt).prop("title",text);
    });
    }
    }
    }
    }
    }]);

     

    Save the file, turn the plugin off and then on again in the web app to make it compile, and then your dates should be fixed.  Let me know if you have issues.

    0
    Comment actions Permalink
  • Avatar
    Michael Wozniak

    Ok, I found out the code I posted above still had issues.  I am not sure if these are caused by the 7.1 upgrade, but at any rate... please fix follow the directions above with this code:

     

    mod.directive('span', [

    function () {
    return {

    transclude: false,
    restrict: 'E',
    link: function link($scope, lmnt, attrs) {
    if ($$get($scope,"$parent.$parent.in.table") && $$get($scope,"$parent.$parent.in.column")){
    if (shouldConvertField($scope.$parent.$parent.in.table,$scope.$parent.$parent.in.column)){
    var text = convertItem($scope.$parent.$parent.in.table,
    $scope.$parent.$parent.in.column,
    $scope.$parent.$parent.member);

    setTimeout(function(){
    $(lmnt).text(text);
    $(lmnt).prop("title",text);
    });
    }
    }
    }
    }
    }]);

    0
    Comment actions Permalink
  • Avatar
    Michael Wozniak

    To make sure the value that displays on the actual filter when you view the dashboard is correct, you must also update the directive for ucBoxText.  Unfortunately I was not able to trim the value successfully.  I have posted my code below.  It successfully sends the value to the convertItem function, but it does not alter it because it is not type "String".  When I tried to convert it to string, I get undefined.  Unfortunately, I am not a jquery expert.  Any help resolving this would be great.  If I had to guess, I bet I need to get the value from somewhere other than $scope.parent.display, but unfortunately trial and error did not yield a successful result.

     

    mod.directive('ucBoxText', [

    function () {
    return {

    transclude: false,
    restrict: 'C',
    link: function link($scope, lmnt, attrs) {

    if ($scope.$parent.in && $scope.$parent.in.table && $scope.$parent.in.column){
    if (shouldConvertField($scope.$parent.in.table,$scope.$parent.in.column)){
    $(lmnt).text(convertItem($scope.$parent.in.table,
    $scope.$parent.in.column,
    $scope.$parent.display));

    }
    else{
    $(lmnt).text($scope.$parent.display);
    }
    }

    }
    }
    }]);

    1
    Comment actions Permalink
  • Avatar
    wendy wang

    This plugin breaks filter > ranking 

    TypeError: Cannot read property 'toLowerCase' of undefined 
    at shouldConvertField (main.cc317a9ee86d3731420a.js:32) 
    at Object.$naming.humanize (main.cc317a9ee86d3731420a.js:32) 
    at y (common.js?g=342dd8bfd58dc567945d4244cb22f29a:1) 
    at Object.getFilterDescription (common.js?g=342dd8bfd58dc567945d4244cb22f29a:1) 
    at Object.getTags (app-main.js?g=342dd8bfd58dc567945d4244cb22f29a:1) 
    at C (app-main.js?g=342dd8bfd58dc567945d4244cb22f29a:1) 
    at Object.filterChange (app-main.js?g=342dd8bfd58dc567945d4244cb22f29a:1) 
    at d.e.apply (app-main.js?g=342dd8bfd58dc567945d4244cb22f29a:1) 
    at app-main.js?g=342dd8bfd58dc567945d4244cb22f29a:1 
    at app-main.js?g=342dd8bfd58dc567945d4244cb22f29a:1

    0
    Comment actions Permalink

Please sign in to leave a comment.