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

Strange issue with .ScriptFilesPath()

4 Answers 53 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Heiko Falk
Top achievements
Rank 1
Heiko Falk asked on 23 Jan 2012, 04:11 PM
Hi,

I moved my Telelrik Scripts from ~/Scripts/2011.3.1115 to ~/Scripts/3rdParty/2011.3.1115. I then changed the default path in my layout page:

@(Html.Telerik().ScriptRegistrar()
.jQuery(false)
.DefaultGroup(group => group
    .DefaultPath("~/Scripts/3rdParty/")
    .Combined(true)
    .Compress(true)))

For Telerik elements in partial view, I have to use
@(Html.Telerik().Grid<Model>()
    .ScriptFilesPath("~/Scripts/3rdParty/")

After having done that all, i deleted the original directory ~/Scripts/2011.3.1115 and now the scripts needed are not found when getting a partial view via ajax. So I undid my delete and now it works again, but then i realised that the scripts are found in the new folder as you can see in my attachment. What is going on here? And is it somehow possible to change the default script path only at one place?

Kind Regards


4 Answers, 1 is accepted

Sort by
0
Heiko Falk
Top achievements
Rank 1
answered on 24 Jan 2012, 05:36 PM
I searched a bit more and found out that the following call is done when getting the partial view:
<script type="text/javascript">
    if(!jQuery.telerik){
    jQuery.ajax({
    url:"/Scripts/3rdParty/2011.3.1115/telerik.common.min.js",
    dataType:"script",
    cache:false,
    success:function(){
    jQuery.telerik.load(["/Scripts/2011.3.1115/jquery-1.6.4.min.js","/Scripts/3rdParty/2011.3.1115/telerik.common.min.js","/Scripts/3rdParty/2011.3.1115/telerik.textbox.min.js","/Scripts/3rdParty/2011.3.1115/telerik.calendar.min.js","/Scripts/3rdParty/2011.3.1115/telerik.datepicker.min.js","/Scripts/3rdParty/2011.3.1115/telerik.grid.min.js","/Scripts/3rdParty/2011.3.1115/telerik.grid.filtering.min.js"],
        function(){ jQuery('#GridKundenListe').tGrid({columns:[{
Take a look at the first file loaded by jquery.telerik.load: jquery-1.6.4.min.js is the only file that doesnt look in /Scripts/3rdParty but in /Scripts/. Why is that so?

Kind Regards
Heiko
0
Daniel
Telerik team
answered on 25 Jan 2012, 05:13 PM
Hi Heiko,

I answered the support ticket (on the same subject) that you submitted. For convenience I am pasting my reply below:
**********************************************************************************************************************
When changing the default path you should use the ScriptRegistrar method, with the new path set, in the Partial View before the Component. Otherwise, there is no way for it to know that the path has been changed and an incorrect script to load the files is returned with the response.

**********************************************************************************************************************

Regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Heiko Falk
Top achievements
Rank 1
answered on 25 Jan 2012, 05:48 PM
Hi Daniel,

unfortunately, this does not solve the problem. As I wrote, In my View calling the partial view with the Grid i code:

@(Html.Telerik().ScriptRegistrar()
.jQuery(false)
.DefaultGroup(group => group
    .DefaultPath("~/Scripts/3rdParty/")
    .Combined(true)
    .Compress(true)))

And it still doesn't work, I get the following error

jQuery("#Grid").tGrid is not a function

To be more clear: when I move all files from /Scripts/2011.3.1115 to /Script/2011.3.1115/ except the file /Scripts/2011.3.1115/jquery-1.6.4.min.js then it works and I don't think that this behaviour is expected.

By the way, it still works, when I removing the ScriptRegistrar from the Layout Page, so I think it is not needed when I load the grid via Ajax.

Regards
Heiko
0
Daniel
Telerik team
answered on 26 Jan 2012, 11:30 AM
Hello Heiko,

The ScriptFilesPath method is used to set the path only for the Telerik script files. The jQuery file path is set with the ScriptRegistrar method.
I attached a sample project with the path changed and the ScriptRegistrar method in the partial view. At least on my side, it works as expected. Could you check it see if I missed something.

Kind regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
Grid
Asked by
Heiko Falk
Top achievements
Rank 1
Answers by
Heiko Falk
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or