【发布时间】:2025-12-15 17:35:01
【问题描述】:
我意识到这可能很愚蠢,这可能是由于我缺乏 javascript/jquery 知识(在重构等方面)
我正在像这样在我的页面上渲染一个 JQGrid 组件。
<script src="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/JQGrid")" type="text/javascript"></script>
<script type="text/javascript">
var colNames = ['S ID', 'Shift Description'];
var colModel = [
{ name: 'S_ID', index: 'S_ID', key: true, width: 55, editable: false, hidden: true, search: false },
{ name: 'Shift_Description', index: 'Shift_Description', width: 100, align: "right", editable: true, editrules: { required: true }, formoptions: { rowpos: 1, colpos: 1}}];
RenderJQGrid("#theGrid", '#pager', '@ViewBag.Title', 600, colNames, colModel, 'S_ID', null, null, null, '@Url.Action("GridData")', '@Url.Action("Add")', '@Url.Action("Edit")', '@Url.Action("Delete")', '@Url.Action("ExportToExcel")');
</script>
在我的 .js 文件中,我只有这个。 (它也是包中唯一的文件)
function RenderJQGrid(GridID, PagerID, Title, ModalWidth, ColNames, ColModel, InitSortCol, OnLoadComplete, EditBeforeShowOptions, AddBeforeShowOptions, URL_get, URL_add, URL_edit, URL_delete, URL_excel) {
... Logic
}
我在 fiddler 中收到了这个错误。
/* 缩小失败。返回未缩小的内容。
(1,10): 运行时错误 CSS1031: Expected selector, found 'RenderJQGrid('
(1,10): 运行时错误 CSS1025: 应为逗号或左大括号,找到 'RenderJQGrid('
*/
我做错了什么/错过了什么?代码嵌入到我的 html 页面中时看起来不错?
【问题讨论】:
标签: javascript jquery refactoring asp.net-mvc-4