We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Documentation Error for Query Builder SetRule method?

Thread ID:

Created:

Updated:

Platform:

Replies:

150968 Jan 26,2020 03:30 PM UTC Jan 29,2020 12:14 PM UTC Blazor 3
loading
Tags: Query Builder
Scott Peal
Asked On January 26, 2020 03:30 PM UTC

On this documentation page it shows 
public QueryBuilderRule ImportRules = new QueryBuilderRule
{
    Condition = "or",
    Rules = new List<RuleModel>{
        new RuleModel { Field = "EmployeeID", Value = "1001", Operator = "notequal" },
        new RuleModel { Field = "Country", Value = "England", Operator = "equal" }
    }
};

private void setRules()
    {
        QueryBuilderObj.SetRules(ImportRules);
    }


However, the SetRules method takes a RuleModel object and not a QueryBuilderRule object in the latest version.

Saranya Dhayalan [Syncfusion]
Replied On January 27, 2020 10:22 AM UTC

Hi Scott, 
 
Sorry for the inconvenience caused. 
 
We have checked your reported issue, we will consider this and correct it in our online documentation site. This documentation will get refreshed in our upcoming release. 
 
Regards, 
Saranya D 


Scott Peal
Replied On January 28, 2020 02:59 PM UTC

Thanks, but know that search is not working for us until we get a working example. 

  • Missing semi-colon in getSQL and getRules methods
  • If we set an import rule then we SetRulesFromSql per the example with a button, the UI updates properly; however, if we call the getSQL method via another button, the returned sql is the original import rule and not the changed rule.
e.g.

    Set Rule
    Get SQL

   
       
           
           
       
   

        protected QueryBuilderRule ImportRules = new QueryBuilderRule()
        {
            Condition = "and",
            Rules = new List()
            {
                new RuleModel { Label="Name", Field="Name", Type="strig", Operator="equal", Value = "Alpha" },
                new RuleModel { Label="Code", Field="Code", Type="string", Operator="equal", Value = "FLKIN" }
            }
        };
        protected void setRules()
        {
            QueryBuilderObj.SetRulesFromSql("Name LIKE ('%Ch%')");
        }
        protected async void getSql()
        {
            RuleModel actRule = new RuleModel()
            {
                Condition = QueryBuilderObj.Rule.Condition,
                Rules = QueryBuilderObj.Rule.Rules
            };
            RuleModel rule = await QueryBuilderObj.GetValidRules(actRule);
            string sql = await QueryBuilderObj.GetSqlFromRules(rule);           // returns the original ImportRules and not the setRules
       }

Saranya Dhayalan [Syncfusion]
Replied On January 29, 2020 12:14 PM UTC

Hi Scott, 
 
Sorry for the inconvenience caused 
 
Query – 1: Missing semi-colon in getSQL and getRules methods 
 
We have checked your reported issue we will consider this and correct it in our online documentation site. This documentation will get refreshed in our upcoming release. 
 
Qurey -2: If we set an import rule then we SetRulesFromSql per the example with a button, the UI updates properly; however, if we call the getSQL method via another button, the returned sql is the original import rule and not the changed rule. 
 
We have checked your reported issue, To Resolve this issue by using GetRules method. Please find the below code snippet: 
 
@using Syncfusion.EJ2.Blazor.QueryBuilder 
@using Syncfusion.EJ2.Blazor.Buttons 
 
<EjsQueryBuilder Columns="@Columns" DataSource="@EmployeeDetails" @ref="QueryBuilderObj" Rule="@ImportRules"></EjsQueryBuilder> 
<EjsButton CssClass="e-primary" @onclick="setRules">Set Rules</EjsButton> 
 
<EjsButton CssClass="e-primary" @onclick="getSql">Get SQL</EjsButton> 
 
@code { 
        EjsQueryBuilder QueryBuilderObj; 
 
    public List<QueryBuilderColumn> Columns = new List<QueryBuilderColumn> 
{ 
    new QueryBuilderColumn{ Field = "EmployeeID", Label = "Employee ID", Type = "number" }, 
    new QueryBuilderColumn{ Field = "FirstName", Label = "First Name", Type = "string" }, 
    new QueryBuilderColumn{ Field = "TitleOfCourtesy", Label ="Title of Courtesy", Type = "boolean"}, 
    new QueryBuilderColumn{ Field = "Title", Label = "Title", Type = "boolean", Values = new List<string>{ "Mr.", "Mrs." } }, 
    new QueryBuilderColumn{ Field = "HireDate", Label = "Hire Date", Type = "date", Format = "MM/dd/yyyy"}, 
    new QueryBuilderColumn{ Field = "Country", Label = "Country", Type="string"}, 
    new QueryBuilderColumn{ Field = "City", Label = "City", Type = "string"} 
}; 
 
    public List<Employee> EmployeeDetails = new List<Employee> 
    { 
        new Employee{ FirstName = "Martin", EmployeeID = "1001", Country = "England", City = "Manchester", HireDate = "23/04/2014" }, 
        new Employee{ FirstName = "Benjamin", EmployeeID = "1002", Country = "England", City = "Birmingham", HireDate = "19/06/2014" }, 
        new Employee{ FirstName = "Stuart", EmployeeID = "1003", Country = "England", City = "London", HireDate = "04/07/2014"}, 
        new Employee{ FirstName = "Ben", EmployeeID = "1004", Country = "USA", City = "California", HireDate = "15/08/2014" }, 
        new Employee{ FirstName = "Joseph", EmployeeID = "1005", Country = "Spain", City = "Madrid", HireDate = "29/08/2014" } 
    }; 
 
    public class Employee 
    { 
        public string FirstName { get; set; } 
        public string EmployeeID { get; set; } 
        public string Country { get; set; } 
        public string City { get; set; } 
        public string HireDate { get; set; } 
    } 
 
    protected QueryBuilderRule ImportRules = new QueryBuilderRule() 
    { 
        Condition = "and", 
        Rules = new List<RuleModel>() 
            { 
                new RuleModel { Label="FirstName", Field="FirstName", Type="strig", Operator="equal", Value = "Martin" }, 
                new RuleModel { Label="EmployeeID", Field="EmployeeID", Type="string", Operator="equal", Value = "1001" } 
            } 
    }; 
    protected void setRules() 
    { 
        QueryBuilderObj.SetRulesFromSql("FirstName LIKE ('%Ch%')"); 
    } 
    protected async void getSql() 
    { 
        RuleModel actRule = await QueryBuilderObj.GetRules();  
        RuleModel rule = await QueryBuilderObj.GetValidRules(actRule); 
        string sql = await QueryBuilderObj.GetSqlFromRules(rule);           // returns the original ImportRules and not the setRules 
    } 
} 
 
 
We will change this code snippet in our documentation site and this documentation will get refreshed in our upcoming release.  
 
For your convenience we have prepared a sample. Please find the below sample link: 
Regards, 
Saranya D 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon