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

Custom DropDown Filter

4 Answers 181 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 2
Thomas asked on 21 May 2014, 10:31 AM
Hey guys,

I'm actually doin' a project where I use a lot grids having the same column and I use a DropDownList to filter the respective column.
The DropDownList Filter is set like in the demo and works fine:

function CategoryFilter(element) {
    element.kendoDropDownList({
        dataSource: {
            transport: {
                read: "/Software/GetSoftwareCategoriesForFilter"
            }
        },
        optionLabel: "--Select Value--"
    });
}

Actually I use this function in every single Grid page to load the categories and it's like having the same function n times what makes it redundant. What I want to do is to bring this method into a separate GeneralFunctions.js file, but this isn't working so far.

The file is loaded correctly added to the bundle:
bundles.Add(new ScriptBundle("~/bundles/scripts")
                .Include("~/Scripts/GeneralFunctions.js"));

and within the Grid I call the function like this:
columns.Bound(c => c.Software.SoftwareCategory.Name).Title("Software Category").Width(150).Filterable(filterable => filterable.UI("CategoryFilter"));

am I missing something?

thx in advance and kind regards
tom

4 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 23 May 2014, 10:19 AM
Hello Tom,

The described approach should work. Could you check if the function is available in the global scope and if there are any JavaScript errors? 

Regards,
Daniel
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
Thomas
Top achievements
Rank 2
answered on 26 May 2014, 06:59 AM
hey daniel.
the function is available in global scope and there are no js errors.

Whats really weird is, that the function seem to work on my localhost only. If I publish the version it's not working anymore.

cheers
tom
0
Thomas
Top achievements
Rank 2
answered on 27 May 2014, 08:28 AM
hey daniel,

just "fixed" the issue more or less by reading the correct path. the project was published to a different folder and that's why the controller action wasn't called. The only thing I had to do was to edit the transport path to "/Folder/Controller/Action".

cheers
tom
0
Accepted
Daniel
Telerik team
answered on 28 May 2014, 06:42 AM
Hello again Tom,

I am glad that you were able to locate and fix the problem. As an alternative approach to modifying the URL, I can also suggest to add a base URL variable in the layout before loading the other scripts and use it for the URLs in the scripts:
<script type="text/javascript">
    var baseUrl = '@Url.Content("~/")';
</script>
read: baseUrl + "Software/GetSoftwareCategoriesForFilter"
This way the URL should be correct with or without virtual path.

Regards,
Daniel
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
Grid
Asked by
Thomas
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Thomas
Top achievements
Rank 2
Share this question
or