JavaScript UI Libraries & Blazor Components Suite – Smart UI Forums General Discussions How to get values from query builder in blazor

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #104236
    Pavan Muram
    Participant

    I would like to get data from query builder after every click event in blazer. I did try ItemClicked unable to use it properly and understand it. Any example will really help

    • This topic was modified 1 year, 5 months ago by Pavan Muram.
    #104248
    ivanpeevski
    Participant

    Hi Pavan,

     

    You can achieve this by using the OnChange Event. The current value of query builder is an array of objects.

    Here is a simple example, where the array value is transformed into string and shown in the page:

    @page “/”
    @using System.Text.Json
    @using System.Text.Json.Serialization

    value is: @currentValue
    <QueryBuilder Fields=”fields” OnChange=”OnChange”></QueryBuilder>

    @code {
    string currentValue = “”;
    QueryBuilder queryBuilder;
    private List<QueryBuilderField> fields = new List<QueryBuilderField>() {
    new QueryBuilderField()
    {
    Label = “Id”,
    DataField = “id”,
    DataType = “number”
    },
    new QueryBuilderField()
    {
    Label = “Product”,
    DataField = “productName”,
    DataType = “string”
    },
    new QueryBuilderField()
    {
    Label = “Unit Price”,
    DataField = “price”,
    DataType = “number”,
    FilterOperations = new string[]{“=”, “<“, “>”}
    },
    new QueryBuilderField()
    {
    Label = “Purchased”,
    DataField = “purchased”,
    DataType = “date”
    },
    new QueryBuilderField()
    {
    Label = “Available”,
    DataField = “available”,
    DataType = “boolean”
    }
    };

    private async void OnChange(Event ev)
    {
    var detail = JsonSerializer.Deserialize<Dictionary<string, dynamic>>(ev[“detail”]);
    currentValue = string.Join(“,”, detail[“value”]);
    }
    }

    Best Regards,
    Ivan Peevski
    Smart UI Team
    https://www.htmlelements.com/

    #104249
    Pavan Muram
    Participant

    Hi Ivan,

    Is it possible to create dropdown with predefined values in the values input box ?

    And the code is throwing RuntimeBinderException that String and dynamic shouldn’t be used. I should use String and Object.

    Even that doesn’t work any thoughts ?

    Thanks,

    Pavan

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.