Active Query Builder support area

How to load (switch) a query on the client? (ASP.NET Edition)

Last modified:


Q:

How to load (switch) a query on the client?

A:

 

The given sample is for the .NET Core environment. Samples of the same for other environments can be found in the ChangeConnection demo for the appropriate environment.

When you need to switch a query,

I. execute this code on the client:

    function onChangeSql(id) {
$.get('/QbController/ChangeSql?id=' + id, function() {
AQB.Web.QueryBuilder.update();
});
}

Instead of the id parameter, you can pass any other information unambiguously identifying the query to load.

If you need to re-load the database schema tree as well, use the fullUpdate method instead of the update.

 

II. use the corresponding code on the server:

        public ActionResult ChangeSql(string id)
{
var qb = _aqbs.Get(instanceId); // instanceId here should match the instanceId on the client
if (qb == null)
{
// the given instance of queryBuilder hasn't yet initialized, initialize a new instance
}
qb.SQL = _dataQueryViewModelService.GetQueryText(id); // somehow get the new SQL query to load and assign to the SQL property
return new EmptyResult();
}

 

Alternatively, if you have the Professional or Enterprise subscription, users can work with several queries at once. In this case, each query on the server should be uniquely identified by the instanceId parameter.

 


Is this article helpful for you?