我通过使用简易查询生成器的演示应用程序将简易查询生成器添加到我的 MVC 项目中,并根据演示项目添加了.css和.js文件。 执行时实体未加载,构造函数和 getModel() 未被调用。情商。加载页面后未定义客户端这是我的代码。
EasyQuery.cshtml( view )
<script type="text/javascript">
window.easyQuerySettings = {
serviceUrl: "/EasyQuery",
modelName: "NWindSQL",
entitiesPanel: { showCheckboxes: true },
columnsPanel: {
allowAggrColumns: true,
attrElementFormat: "{entity} {attr}",
showColumnCaptions: true,
adjustEntitiesMenuHeight: false,
menuOptions: {
showSearchBoxAfter: 30,
activateOnMouseOver: true
}
},
queryPanel: {
showPoweredBy: false,
alwaysShowButtonsInPredicates: false,
adjustEntitiesMenuHeight: false,
menuOptions: {
showSearchBoxAfter: 20,
activateOnMouseOver: true
}
},
syncQueryOptions: {
sqlOptions: { SelectDistinct: true }
},
};
function getPrefix() {
var res = window.location.pathname;
if (res.charAt(res.length - 1) !== '/')
res = res + '/';
return res;
}
</script>
<div class="entities-panel-container">
<div id="EntitiesPanel"></div>
</div>
<div class="columns-panel-container">
<div id="ColumnsPanel"></div>
</div>
<div class="query-panel-container">
<div id="QueryPanel"></div>
</div>
<script type="text/javascript">
**$(function () {
var query = EQ.client.getQuery();
EQ.client.loadModel({ modelName: "Model1" });
});**
</script>
在 EasyQueryController 中.cs
public class **EasyQueryController** : Controller
{
private EqServiceProviderDb eqService;
public **EasyQueryController()**
{
eqService = new EqServiceProviderDb();
eqService.SessionGetter = key => Session[key];
eqService.SessionSetter = (key, value) => Session[key] = value;
eqService.StoreQueryInSession = true;
eqService.Formats.SetDefaultFormats(FormatType.MsSqlServer);
eqService.Formats.UseSchema = false;
string dataPath = System.Web.HttpContext.Current.Server.MapPath("~/App_Data");
eqService.DataPath = dataPath;
eqService.Connection = new SqlConnection("Data Source=" + System.IO.Path.Combine(dataPath, "Northwind.sdf"));
}
[HttpPost]
public ActionResult GetModel(string modelName)
{
var model = eqService.GetModel(modelName);
return Json(model.SaveToDictionary());
}
。
}
我是否需要更改一些代码或包含一些其他功能来填充 EQ。客户端元素。?
我没有看到您在查看页面上实际包含EasyQuery脚本的位置。在视图页面的末尾(关闭"body"标记之前)必须有类似于以下标记的内容:
<script src="http://cdn.korzh.com/eq/3.6.0/eq.all.min.js" type="text/javascript"></script>
<script src="http://cdn.korzh.com/eq/3.6.0/eq.view.basic.js" type="text/javascript"></script>