Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
filtering in reports
Gaurav Singhal
<p>Hi,</p><p> </p><p>I am new to birt. I want to create a report and in the column headers implement some kind of filtering. We have thought of creating a text box in column header and allow users put in for example "A" in it. On press of filter button/label again in the report header, it should open same report with only rows starting with "A" for that column. Any suggestions how we can implement it.</p><p> </p><p>we tried using dynamic text objects and creating textbox thorugh that but then on press of button we are not able to understand how to pick value from it and then pass as drilldown in filter. we do not want to display the parameters dialog box to users.</p><p> </p><p>Thanks in advance.</p><p>Gaurav</p>
Find more posts tagged with
Comments
kclark
<p>Have you tried a hidden parameter and a query like this?</p><pre class="_prettyXprint">select * from customers where customername like '%" + params["filterkey"].value + "%'</pre><p>I created the following text item:</p><pre class="_prettyXprint"><script> function go() { var param = document.getElementById('filter').value; var newrpt = "http://127.0.0.1:62905/viewer/frameset?__report=%2Fhome%2Fkclark%2Fexamples%2Ffilter%2Fnew_report.rptdesign&filterkey=" + param; window.location = newrpt; }</script>Filter:<br><input type="text" id="filter"><br><input type="submit" value="Submit" onClick="go();"></pre><p>Then used this in the beforeOpen of the data set</p><pre class="_prettyXprint">if(params["filterkey"].value != "none") { this.queryText = "select * from customers where customername like '%" + params["filterkey"].value + "%'";}</pre><p>I've attached my example, enter "Ate" in the text box then click the submit button.</p>
kclark
<p>Here's another example that I wrote up real quick, take a look at the rptdesign</p><p> </p><p>
Gaurav Singhal
<p>Thanks <span style="font-size:14px;">Kristopher </span>for your answers and quick response. We were trying your first approach only but what we were not able to do was to end the filter in the url. We were not able to retrieve its value in beforeopen and other functions. But I now understand that we shoudl pass the filter etc back in the url from the same java. This is what we were trying to do</p><pre class="_prettyXprint _lang-js">var reportRunnable = reportContext.getReportRunnable();var reportDesign = reportRunnable.getDesignInstance();ac = StructureFactory.createAction();ah = reportContext.getDesignHandle().findElement("filter_btn").setAction( ac );ah.setLinkType("drill-through");ah.setReportName("SummeryReport.rptdesign");ah.setTargetFileType("report-design");ah.setTargetWindow("_self");pb = StructureFactory.createParamBinding();pb.setParamName("filter");/*pb.setExpression(<VALUE-OF format="String">reportContext.getDesignHandle().findElement("filter_btn")</VALUE-OF>);*//*pb.setExpression(params["filter"].value);*/pb.setExpression(<VALUE-OF format="String">document.getElementById('cl1Id').value</VALUE-OF>);ah.addParamBinding(pb); pb = StructureFactory.createParamBinding();pb.setParamName("parentGeoId");pb.setExpression(params["parentGeoId"].value);ah.addParamBinding(pb);pb = StructureFactory.createParamBinding();pb.setParamName("parentClassId");pb.setExpression(params["parentClassId"].value);ah.addParamBinding(pb);pb = StructureFactory.createParamBinding();pb.setParamName("reportingClassId");pb.setExpression(params["reportingClassId"].value);ah.addParamBinding(pb);pb = StructureFactory.createParamBinding();pb.setParamName("start_date");pb.setExpression(<VALUE-OF format="yyyy-MM-dd" >params["start_date"].value</VALUE-OF>);ah.addParamBinding(pb);pb = StructureFactory.createParamBinding();pb.setParamName("end_date");pb.setExpression(<VALUE-OF format="yyyy-MM-dd" >params["end_date"].value</VALUE-OF>);ah.addParamBinding(pb);pb = StructureFactory.createParamBinding();pb.setParamName("start_time");pb.setExpression(params["start_time"].value);ah.addParamBinding(pb);pb = StructureFactory.createParamBinding();pb.setParamName("end_time");pb.setExpression(params["end_time"].value);ah.addParamBinding(pb);pb = StructureFactory.createParamBinding();pb.setParamName("in_phase");pb.setExpression(params["in_phase"].value);ah.addParamBinding(pb);pb = StructureFactory.createParamBinding();pb.setParamName("company_id");pb.setExpression(params["company_id"].value);ah.addParamBinding(pb);pb = StructureFactory.createParamBinding();pb.setParamName("feederCategoryId");pb.setExpression(params["feederCategoryId"].value);ah.addParamBinding(pb);pb = StructureFactory.createParamBinding();pb.setParamName("time_Param");pb.setExpression(params["time_Param"].value);ah.addParamBinding(pb);pb = StructureFactory.createParamBinding();pb.setParamName("Geography_hierarchy");pb.setExpression(params["Geography_hierarchy"].value);ah.addParamBinding(pb);</pre><p> obviously document was not available there. So now I do understand that we will have to create the complete url there itself. Just wanted to understand further that the other parameters can be directly picked in the javascript using value of function?</p><p> </p><p>Thanks!</p><p>Gaurav</p>