This is a migrated thread and some comments may be shown as answers.

Custom Parameter Editor - Dropdown Menu

3 Answers 357 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Moses Fetters
Top achievements
Rank 1
Moses Fetters asked on 10 Feb 2015, 07:54 PM
Hi Everyone,

I've been trying to create a new report using a drop down list for parameters, but instead of a drop down, I'm getting a select list.  I followed the howto How To: Create a Custom Parameter Editor and added the JavaScript into my view (using MVC 5, Telerik Q3 2014 SP1 8.2.14.1204), as well as ensuring that the dropdownelement was using ".html" instead of ".htmll" (Error Found: How To Create a Custom Parameter Editor).  Any help would be appreciated.

@section header
{
    @Styles.Render("~/Content/telerikCss")
    <style type="text/css">
        #telerikReportViewer
        {
            overflow: hidden;
            width: 100%;
            height: 595px;
            min-height: 595px;
        }
    </style>
}
 
<div class="row">
    <div class="col-lg-12">
        @{
            var typeReportSource = new TypeReportSource { TypeName = Model.SelectedReportName };
 
            if (typeReportSource.TypeName == "")
            {
                typeReportSource.TypeName = null;
            }
        }
 
        @(Html.TelerikReporting().ReportViewer().Id("telerikReportViewer")
              .ServiceUrl(@Url.Content("~/api/reports/"))
              .TemplateUrl(@Url.Content("~/Content/ReportViewer/templates/telerikReportViewerTemplate-8.2.14.1204.html"))
              .ReportSource(typeReportSource)
              .ViewMode(ViewModes.PRINT_PREVIEW)
              .ScaleMode(ScaleModes.SPECIFIC)
              .Scale(1.0)
              .PersistSession(false)
              )
    </div>
</div>
 
@section scripts
{
    @Scripts.Render("~/bundles/reportsJS")
    <script type="text/javascript">
 
        $(document).ready(function() {
            $("#telerikReportViewer")
            .telerik_ReportViewer({
                parameterEditors: [
                    {
                        match: function (parameter) {
                            return Boolean(parameter.availableValues) && !parameter.multivalue;
                        },
 
                        createEditor: function (placeholder, options) {
                            var dropDownElement = $(placeholder).html('<div></div>'),
                                      parameter,
                                      valueChangedCallback = options.parameterChanged,
                                      dropDownList;
 
                            function onChange() {
                                var val = dropDownList.value();
                                valueChangedCallback(parameter, val);
                            }
 
                            return {
                                beginEdit: function (param) {
 
                                    parameter = param;
 
                                    $(dropDownElement).kendoDropDownList({
                                        dataTextField: "name",
                                        dataValueField: "value",
                                        dataSource: parameter.availableValues,
                                        change: onChange
                                    });
 
                                    dropDownList = $(dropDownElement).data("kendoDropDownList");
                                }
                            };
                        }
                    }]
            });
        });
    </script>
}

3 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 12 Feb 2015, 09:42 AM
Hello Moses,

The parameterEditor option is available only for the HTML5 Report Viewer jQuery widget. The MVC wrapper does not provide yet such option, and it is logged in our system for improvement. Thus you can remove the MVC wrapper from the page and leave only the jQuery object.

If you want to raise the priority of the task, feel free to log it in our public feedback portal where features are considered for implementation based on the demand for them.


Let us know if you have any further questions.

Regards,
Stef
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Shane
Top achievements
Rank 1
answered on 17 Feb 2015, 05:59 PM
Is there a way to, create the report with mvc razor, and then use jquery to set $("#ReportViewer1") parameterEditors?

0
Stef
Telerik team
answered on 19 Feb 2015, 12:09 PM
Hi Shane,

The parameterEditors setting must be applied on creating the viewer object, which is supported only with the jQuery widget. The MVC wrapper of the widget does not support setting custom parameters editors yet. Note that the wrapper will produce the same jQuery widget that you can set initially in the view.

Regards,
Stef
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
General Discussions
Asked by
Moses Fetters
Top achievements
Rank 1
Answers by
Stef
Telerik team
Shane
Top achievements
Rank 1
Share this question
or