SPJS Chart Date Filter

Forums SPJS Charts for SharePoint SPJS Chart Date Filter

  • This topic has 2 replies, 2 voices, and was last updated 7 years ago by Jhap.
Viewing 1 reply thread
  • Author
    Posts
    • #6284
      Jhap
      Participant

      Good day Sir Alexander,

      I use the below code to filter the charts and my calculated column DATEFILTER in sharepoint list is =TEXT(DATE, “DD/MMM/YYYY”) and is working fine, but in the charts the filter shows string;#21/Sep/2014 and because of that it return No items match this filter…

      function spjs_getFilterValue(list,field){
      var q = “”;
      var res = spjs.charts.qItems({“listName”:list,”query”:q,”viewFields”:[field]});
      var b = [];
      var fObj = {};
      $.each(res.items,function(i,item){
      if(fObj[item[field]] === undefined){
      fObj[item[field]] = 1;
      b.push({“f”:””+item[field]+””,”v”:””+item[field]});
      }
      });
      return b;
      }
      var myCustomFilterOptions = spjs_getFilterValue(“{3DE38E73-F09F-40E7-A580-835513FBB638}”,”DateFilter”);

      Thank you very much.

    • #6301
      Alexander Bautz
      Keymaster

      Hi,
      When using a calculated column the value returned from the query is delimited with ;# and we have to strip this out.

      Change the function like this (new code in bold font):

      fObj[item[field]] = 1;
      if(item[field].split(“;#”).length > 1){
      item[field] = item[field].split(“;#”)[1];
      }

      b.push({“f”:””+item[field]+””,”v”:””+item[field]});

      Alexander

      • #6345
        Jhap
        Participant

        Hi Sir Alexander,

        Sorry for the late response due to eid holiday here. I had applied the solution you provided and its working very fine.

        Thank you so much for the kind help.

        Danny

Viewing 1 reply thread
  • You must be logged in to reply to this topic.