0

I have added the Easy Query Builder in to my MVC project by using the demo application of Easy Query Builder and i have added the .css and .js file according to the demo project. while executing the entity is not getting loaded and the constructor and the getModel() is not been invoked. The EQ.Client is undefined once the page is loaded Here is my code.

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>

in the 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());
        }

...
}

should i need to change some code or include some other feature to fill the EQ.Client element.?

Gowthaman
  • 790
  • 1
  • 10
  • 29

1 Answers1

2

I don't see where you actually include EasyQuery scripts on your view page. There must be something like the following markup at the end (before closing "body" tag) of your view page:

<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>
Sergiy
  • 1,912
  • 2
  • 16
  • 25
  • I have same problem , and scripts are added, still entity list is empty – Reza Feb 15 '18 at 19:13
  • It must be something wrong with model loading on the server side or GetModel request isn't sent at all. Open Developer Tools in your browser, refresh the page and check the requests on Network tab. – Sergiy Feb 17 '18 at 06:52