<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Custom visual text input (search) in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Custom-visual-text-input-search/m-p/24604#M680</link>
    <description>&lt;P&gt;Hi, thanks for your replay. I tried web service as well but it is the same.&lt;BR /&gt;&lt;BR /&gt;I will share my code here:&lt;/P&gt;&lt;PRE&gt;module powerbi.visuals {
    export interface CategoryViewModel {
        value: string;
        identity: string;
        color: string;
    }

    export interface ValueViewModel {
        values: any[];
    }

    export interface ViewModel {
        header: any;
        values: ValueViewModel[];
    }

    export class MySlicer implements IVisual {
        public static capabilities: VisualCapabilities = {
            // This is what will appear in the 'Field Wells' in reports
            dataRoles: [
                {
                    name: 'Category',
                    kind: powerbi.VisualDataRoleKind.Grouping,
                }
            ],
            // This tells power bi how to map your roles above into the dataview you will receive
            dataViewMappings: [{
                categorical: {
                    categories: {
                        for: { in: 'Category' },
                        dataReductionAlgorithm: { top: {} }
                    }
                }
            }],
            // Objects light up the formatting pane
            objects: {
                general: {
                    displayName: data.createDisplayNameGetter('Visual_General'),
                    properties: {
                        formatString: {
                            type: { formatting: { formatString: true } },
                        },
                    },
                },
            }
        };

        public static converter(dataView: DataView, colors: IDataColorPalette): ViewModel {
            var viewModel: ViewModel = {
                header: 'Default Header',
                values: []
            }
            if (dataView) {
                var data = dataView.categorical.categories;
                var metadata = dataView.metadata;
                
                viewModel.header = metadata.columns[0].displayName;
                if (data &amp;amp;&amp;amp; data.length &amp;gt; 0) {
                    for (var i = 0, catLength = data[0].values.length; i &amp;lt; catLength; i++) {
                        viewModel.values.push(data[0].values[i]);
                    }
                }
            }

            return viewModel;
        }

        private hostContainer: JQuery;
        private table: D3.Selection;
        private tHead: D3.Selection;
        private tBody: D3.Selection;
        private colorPalette: IDataColorPalette;
        private searchInput: D3.Selection;
        private searchString: string;

        /** This is called once when the visual is initialially created */
        public init(options: VisualInitOptions): void {
            this.colorPalette = options.style.colorPalette.dataColors;
            // element is the element in which your visual will be hosted.
            this.hostContainer = options.element.css('overflow-x', 'hidden');
            this.searchInput = d3.select(options.element.get(0))
                .append("input")
                .classed("my-input", true)
                .attr("type", "text");
            this.table = d3.select(options.element.get(0))
                .append("table")
                .classed('powerbi-sample-table', true);

            this.tHead = this.table.append('thead').append('tr').append('th');
            this.tBody = this.table.append('tbody');
            
            var slicerVisual = this;
            this.searchInput.on("keyup", function () {
                var searchString = slicerVisual.searchString =  $(this).val().toLowerCase();
                slicerVisual.onSearchInput(slicerVisual, searchString);
            });
        }
        
        public onSearchInput(slicerVisual, searchString) {
            var tds = slicerVisual.hostContainer.find("tbody tr");
            tds.each(function() {
                var rowString = $(this).text().toLowerCase();
                if(!searchString || rowString.indexOf(searchString) &amp;gt; -1)
                    $(this).removeClass("hidden");
                else
                    $(this).addClass("hidden");
            })
        }

        /** Update is called for data updates, resizes &amp;amp; formatting changes */
        public update(options: VisualUpdateOptions) {
            var dataViews = options.dataViews;
            if (!dataViews) return;

            this.updateContainerViewports(options.viewport);

            var viewModel = MySlicer.converter(dataViews[0], this.colorPalette);
            var slicerTitle = this.tHead.text(viewModel.header);
            var slicerData = this.tBody;
            this.tBody.html("");
            for(var row in viewModel.values) {
                var rowString = viewModel.values[row] + "";
                rowString = rowString.toLowerCase();
                if(!this.searchString || rowString.indexOf(this.searchString) &amp;gt; -1)
                    slicerData.append('tr').append('td').text(viewModel.values[row]);
                else    
                    slicerData.append('tr').classed("hidden", true).append('td').text(viewModel.values[row]);
            }
        }

        private updateContainerViewports(viewport: IViewport) {
            var width = viewport.width;
            var height = viewport.height;

            this.tHead.classed('dynamic', width &amp;gt; 400);
            this.tBody.classed('dynamic', width &amp;gt; 400);

            this.hostContainer.css({
                'height': height,
                'width': width
            });
            this.table.attr('width', width);
        }
        
        private format(d: number){
            var prefix = d3.formatPrefix(d);
            return d3.round(prefix.scale(d),2) + ' ' +prefix.symbol
        }
    }
}&lt;/PRE&gt;</description>
    <pubDate>Thu, 24 Mar 2016 09:50:31 GMT</pubDate>
    <dc:creator>Silko</dc:creator>
    <dc:date>2016-03-24T09:50:31Z</dc:date>
    <item>
      <title>Custom visual text input (search)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-visual-text-input-search/m-p/24447#M677</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have created a custom visual with a text input, which I wanted to use for a search through slicer. For the start I made just a search through table. It worked perfectly fine on development tools.&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="search.png" style="width: 774px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/3590iE80B8F785FA57627/image-dimensions/774x378?v=v2" width="774" height="378" role="button" title="search.png" alt="search.png" /&gt;&lt;/span&gt;﻿&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="search1.png" style="width: 741px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/3587i9BE10E821814AA94/image-dimensions/741x367?v=v2" width="741" height="367" role="button" title="search1.png" alt="search1.png" /&gt;&lt;/span&gt;﻿&lt;/P&gt;&lt;P&gt;But when I import it into power bi desktop I can't use the input. It looks like it is disabled or&amp;nbsp;keyboard events are not being processed.&amp;nbsp;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="desktop.png" style="width: 750px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/3589iBCEA53E4CB76BDC2/image-dimensions/750x414?v=v2" width="750" height="414" role="button" title="desktop.png" alt="desktop.png" /&gt;&lt;/span&gt;﻿&lt;BR /&gt;Why is that?&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2016 11:53:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-visual-text-input-search/m-p/24447#M677</guid>
      <dc:creator>Silko</dc:creator>
      <dc:date>2016-03-23T11:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: Custom visual text input (search)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-visual-text-input-search/m-p/24573#M679</link>
      <description>&lt;P&gt;This is a great concept - I'd really like to help get it working. Can you share your code so far? Github?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have you tried publishing that PBI Desktop file to the PBI web service and testing it there?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2016 01:42:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-visual-text-input-search/m-p/24573#M679</guid>
      <dc:creator>mike_honey</dc:creator>
      <dc:date>2016-03-24T01:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: Custom visual text input (search)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-visual-text-input-search/m-p/24604#M680</link>
      <description>&lt;P&gt;Hi, thanks for your replay. I tried web service as well but it is the same.&lt;BR /&gt;&lt;BR /&gt;I will share my code here:&lt;/P&gt;&lt;PRE&gt;module powerbi.visuals {
    export interface CategoryViewModel {
        value: string;
        identity: string;
        color: string;
    }

    export interface ValueViewModel {
        values: any[];
    }

    export interface ViewModel {
        header: any;
        values: ValueViewModel[];
    }

    export class MySlicer implements IVisual {
        public static capabilities: VisualCapabilities = {
            // This is what will appear in the 'Field Wells' in reports
            dataRoles: [
                {
                    name: 'Category',
                    kind: powerbi.VisualDataRoleKind.Grouping,
                }
            ],
            // This tells power bi how to map your roles above into the dataview you will receive
            dataViewMappings: [{
                categorical: {
                    categories: {
                        for: { in: 'Category' },
                        dataReductionAlgorithm: { top: {} }
                    }
                }
            }],
            // Objects light up the formatting pane
            objects: {
                general: {
                    displayName: data.createDisplayNameGetter('Visual_General'),
                    properties: {
                        formatString: {
                            type: { formatting: { formatString: true } },
                        },
                    },
                },
            }
        };

        public static converter(dataView: DataView, colors: IDataColorPalette): ViewModel {
            var viewModel: ViewModel = {
                header: 'Default Header',
                values: []
            }
            if (dataView) {
                var data = dataView.categorical.categories;
                var metadata = dataView.metadata;
                
                viewModel.header = metadata.columns[0].displayName;
                if (data &amp;amp;&amp;amp; data.length &amp;gt; 0) {
                    for (var i = 0, catLength = data[0].values.length; i &amp;lt; catLength; i++) {
                        viewModel.values.push(data[0].values[i]);
                    }
                }
            }

            return viewModel;
        }

        private hostContainer: JQuery;
        private table: D3.Selection;
        private tHead: D3.Selection;
        private tBody: D3.Selection;
        private colorPalette: IDataColorPalette;
        private searchInput: D3.Selection;
        private searchString: string;

        /** This is called once when the visual is initialially created */
        public init(options: VisualInitOptions): void {
            this.colorPalette = options.style.colorPalette.dataColors;
            // element is the element in which your visual will be hosted.
            this.hostContainer = options.element.css('overflow-x', 'hidden');
            this.searchInput = d3.select(options.element.get(0))
                .append("input")
                .classed("my-input", true)
                .attr("type", "text");
            this.table = d3.select(options.element.get(0))
                .append("table")
                .classed('powerbi-sample-table', true);

            this.tHead = this.table.append('thead').append('tr').append('th');
            this.tBody = this.table.append('tbody');
            
            var slicerVisual = this;
            this.searchInput.on("keyup", function () {
                var searchString = slicerVisual.searchString =  $(this).val().toLowerCase();
                slicerVisual.onSearchInput(slicerVisual, searchString);
            });
        }
        
        public onSearchInput(slicerVisual, searchString) {
            var tds = slicerVisual.hostContainer.find("tbody tr");
            tds.each(function() {
                var rowString = $(this).text().toLowerCase();
                if(!searchString || rowString.indexOf(searchString) &amp;gt; -1)
                    $(this).removeClass("hidden");
                else
                    $(this).addClass("hidden");
            })
        }

        /** Update is called for data updates, resizes &amp;amp; formatting changes */
        public update(options: VisualUpdateOptions) {
            var dataViews = options.dataViews;
            if (!dataViews) return;

            this.updateContainerViewports(options.viewport);

            var viewModel = MySlicer.converter(dataViews[0], this.colorPalette);
            var slicerTitle = this.tHead.text(viewModel.header);
            var slicerData = this.tBody;
            this.tBody.html("");
            for(var row in viewModel.values) {
                var rowString = viewModel.values[row] + "";
                rowString = rowString.toLowerCase();
                if(!this.searchString || rowString.indexOf(this.searchString) &amp;gt; -1)
                    slicerData.append('tr').append('td').text(viewModel.values[row]);
                else    
                    slicerData.append('tr').classed("hidden", true).append('td').text(viewModel.values[row]);
            }
        }

        private updateContainerViewports(viewport: IViewport) {
            var width = viewport.width;
            var height = viewport.height;

            this.tHead.classed('dynamic', width &amp;gt; 400);
            this.tBody.classed('dynamic', width &amp;gt; 400);

            this.hostContainer.css({
                'height': height,
                'width': width
            });
            this.table.attr('width', width);
        }
        
        private format(d: number){
            var prefix = d3.formatPrefix(d);
            return d3.round(prefix.scale(d),2) + ' ' +prefix.symbol
        }
    }
}&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Mar 2016 09:50:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-visual-text-input-search/m-p/24604#M680</guid>
      <dc:creator>Silko</dc:creator>
      <dc:date>2016-03-24T09:50:31Z</dc:date>
    </item>
    <item>
      <title>Re: Custom visual text input (search)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-visual-text-input-search/m-p/34721#M1044</link>
      <description>&lt;P&gt;If someone didn't see, Microsoft already made custom visual with search capability. It is called Attribute Slicer. You can find it here:&lt;BR /&gt;&lt;A href="https://app.powerbi.com/visuals/show/AttributeSlicer1652434005853" target="_blank"&gt;https://app.powerbi.com/visuals/show/AttributeSlicer1652434005853&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 10:52:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-visual-text-input-search/m-p/34721#M1044</guid>
      <dc:creator>Silko</dc:creator>
      <dc:date>2016-05-11T10:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: Custom visual text input (search)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-visual-text-input-search/m-p/200786#M6408</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any progress on this topic?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Frank&lt;/P&gt;</description>
      <pubDate>Sun, 25 Jun 2017 09:38:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-visual-text-input-search/m-p/200786#M6408</guid>
      <dc:creator>Goofr</dc:creator>
      <dc:date>2017-06-25T09:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: Custom visual text input (search)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-visual-text-input-search/m-p/201218#M6423</link>
      <description>&lt;P&gt;Could you please clarify API version that you use?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Ignat Vilesov&lt;/STRONG&gt;,&lt;/P&gt;&lt;P&gt;Software Engineer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Microsoft Power BI Custom Visuals&lt;/P&gt;&lt;P&gt;&lt;A href="mailto:pbicvsupport@microsoft.com" target="_blank"&gt;pbicvsupport@microsoft.com&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 10:20:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-visual-text-input-search/m-p/201218#M6423</guid>
      <dc:creator>v-viig</dc:creator>
      <dc:date>2017-06-26T10:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: Custom visual text input (search)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-visual-text-input-search/m-p/340232#M10059</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking for some help and Request you to please help me withan issue. I ran into a problem using Search Text Slicer. I have column Values as Co01, C0101, Co0102. Co0101, Co0102 are branches of the Co01. When I give input in the Search Bar with "Co01", total sale also includes&amp;nbsp;&lt;SPAN&gt;Co0101 and Co0102. This is acts pretty much as a LIKE operator (Co01%). How Can i use the same visual or the same code to only take Co01 and not to include Co0101/Co0102.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;TO be simple, search data to the exact search phrase and not to act as LIKE operator functionality&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2018 18:26:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-visual-text-input-search/m-p/340232#M10059</guid>
      <dc:creator>trinathreddy</dc:creator>
      <dc:date>2018-01-17T18:26:24Z</dc:date>
    </item>
    <item>
      <title>Re: Custom visual text input (search)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-visual-text-input-search/m-p/340568#M10073</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/26791"&gt;@trinathreddy&lt;/a&gt;&amp;nbsp;Are you talking about &lt;A href="https://appsource.microsoft.com/en-us/product/power-bi-visuals/WA104381309?src=office" target="_blank"&gt;Text Filter&lt;/A&gt; custom visual?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ignat Vilesov,&lt;/P&gt;&lt;P&gt;Software Engineer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Microsoft Power BI Custom Visuals&lt;/P&gt;&lt;P&gt;&lt;A href="mailto:pbicvsupport@microsoft.com" target="_blank"&gt;&lt;SPAN&gt;pbicvsupport@microsoft.com&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2018 08:52:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-visual-text-input-search/m-p/340568#M10073</guid>
      <dc:creator>v-viig</dc:creator>
      <dc:date>2018-01-18T08:52:13Z</dc:date>
    </item>
    <item>
      <title>Re: Custom visual text input (search)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-visual-text-input-search/m-p/341067#M10100</link>
      <description>&lt;P&gt;Hi V-Viig,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the Help. Yes, this is about Text Filter. The typed input basically works as % wildcard functionality. request you to please the develoepr know that, there are some instances people search for exact phrase.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Smart filer by OKVIZ &lt;A href="https://okviz.com/smart-filter/" target="_self"&gt;(https://okviz.com/smart-filter/)&lt;/A&gt;&amp;nbsp;works exactly the same&amp;nbsp; as I want. But Search Text filter works much faster than Smart Filter. This fucntionality would be a great relief to look at quick insights about how a particular account annual sales.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To be Clear below is the Problem:&lt;/P&gt;&lt;P&gt;Current Funcationality: It takes what ever the input is and tries to match column values&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expected: If ABC and AB are the values, We need sales for only AB. It should not include ABC too. Please let me know if any questions.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2018 18:18:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-visual-text-input-search/m-p/341067#M10100</guid>
      <dc:creator>trinathreddy</dc:creator>
      <dc:date>2018-01-18T18:18:55Z</dc:date>
    </item>
    <item>
      <title>Re: Custom visual text input (search)</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-visual-text-input-search/m-p/341410#M10108</link>
      <description>&lt;P&gt;Thank you for the clarification.&lt;/P&gt;&lt;P&gt;This feature request will be reported to developer to consider in upcoming versions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Ignat Vilesov,&lt;/P&gt;&lt;P&gt;Software Engineer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Microsoft Power BI Custom Visuals&lt;/P&gt;&lt;P&gt;&lt;A href="mailto:pbicvsupport@microsoft.com" target="_blank"&gt;&lt;SPAN&gt;pbicvsupport@microsoft.com&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 07:24:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-visual-text-input-search/m-p/341410#M10108</guid>
      <dc:creator>v-viig</dc:creator>
      <dc:date>2018-01-19T07:24:38Z</dc:date>
    </item>
  </channel>
</rss>

