我有一个使用Telerik Grid控件的MVC站点。
当我使用他们的ScriptRegistrar包含所需的.js文件时,一切正常,它包含的文件是:
telerik.common.min.js
telerik.textbox.min.js
telerik.calendar.min.js
telerik.datepicker.min.js
telerik.grid.min.js
telerik.grid.filtering.min.js
但是,如果我使用
包含这些相同的文件<script type="text/javascript" src="/Scripts/telerik.common.min.js"></script>
....*all the others*....
并完全取出ScriptRegistrar(我想这样做,因为我想使用MVC4捆绑支持)网格无法正确加载。
答案 0 :(得分:0)
问题的原因是ScriptRegisterar将一些JQuery脚本添加到您的页面中以进行启动操作。我想我有两个解决方法:
<强>第一强>
您可以通过ScriptRegisterar添加“telerik.common.min.js”文件,并通过MVC 4捆绑组件添加其他telerik脚本文件。如果这样做,Telerik会尝试在运行时加载相关的脚本文件。例如,如果页面中有ComboBox,Telerik会在页面加载后添加一些脚本来加载脚本。如果先前已加载,则忽略加载。
OR
<强>第二强>
您可以找到并分析注入的启动脚本文件。当我检查时,它可能是这样的(但需要进一步的投入)
<script type="text/javascript">
//<![CDATA[
jQuery(document).ready(function(){
if(!jQuery.telerik) jQuery.telerik = {};
jQuery.telerik.cultureInfo={"shortDate":"yyyy/MM/dd","longDate":"yyyy/MM/dd","longTime":"hh:mm:ss tt","shortTime":"hh:mm tt","fullDateTime":"yyyy/MM/dd hh:mm:ss tt","sortableDateTime":"yyyy\u0027-\u0027MM\u0027-\u0027dd\u0027T\u0027HH\u0027:\u0027mm\u0027:\u0027ss","universalSortableDateTime":"yyyy\u0027-\u0027MM\u0027-\u0027dd HH\u0027:\u0027mm\u0027:\u0027ss\u0027Z\u0027","generalDateShortTime":"yyyy/MM/dd hh:mm tt","generalDateTime":"yyyy/MM/dd hh:mm:ss tt","monthDay":"MMMM dd","monthYear":"MMMM, yyyy","days":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"abbrDays":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"shortestDays":["Su","Mo","Tu","We","Th","Fr","Sa"],"abbrMonths":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",""],"months":["January","February","March","April","May","June","July","August","September","October","November","December",""],"am":"ق.ظ","pm":"ب.ظ","dateSeparator":"/","timeSeparator":":","firstDayOfWeek":0,"currencydecimaldigits":2,"currencydecimalseparator":"/","currencygroupseparator":",","currencygroupsize":3,"currencynegative":3,"currencypositive":2,"currencysymbol":"ريال","numericdecimaldigits":2,"numericdecimalseparator":".","numericgroupseparator":",","numericgroupsize":3,"numericnegative":3,"percentdecimaldigits":2,"percentdecimalseparator":".","percentgroupseparator":",","percentgroupsize":3,"percentnegative":0,"percentpositive":0,"percentsymbol":"%"};
//]]>
</script>
答案 1 :(得分:0)
我认为避免使用脚本注册商是不可能的(或者说是可行的)。如果要单独加载资源文件(.css / .js),则可以执行此操作。
您仍然需要在页面上使用脚本注册器,因为它根据您在telerik控件(例如Grid)上进行的自定义“注入”自定义javascript。