FlexGridSearch clearing

Posted by: elogsdon on 16 September 2020, 4:49 am EST

  • Posted 16 September 2020, 4:49 am EST

    I am using the sample at https://demos.componentone.com/ASPNET/MVCExplorer/FlexGrid/Searching to add a search to my FlexGrid. I am unable to clear the search text and show all the grid data again. I have tried deleting the text and clicking on the "X" on the control. Only entering a blank resets the search to show all the data again. I don't see anything obvious in the sample I referenced above.
    @using (Html.BeginForm("Save", "Bill"))
    {
    @Html.AntiForgeryToken()
    @(Html.C1().FlexGrid().Id("policyGrid")
    .CssClass("custom")
    .IsReadOnly(true)
    .SortingType(C1.Web.Mvc.Grid.AllowSorting.SingleColumn)
    .Bind(ib => ib.Update(Url.Action("GridUpdate")).OnClientQueryComplete("UpdateComplete")
    .Create(Url.Action("GridCreate"))
    .Delete(Url.Action("GridDelete"))
    .DisableServerRead(true)
    .Bind(Model.Policies))
    .AutoGenerateColumns(false)
    .AlternatingRowStep(0)
    .IsReadOnly(false)
    .ShowColumnFooters(true, "Total")
    .Columns(c =>
    {
    foreach (var col in Model.ColumnList)
    {
    c.Add(col);
    }
    })
    .AllowAddNew(true)
    .AllowDelete(true)
    .ShowErrors(true)
    .OnClientLoadedRows("fixDefaultJSAlert"))

    @(Html.C1().FlexGridSearch("#searchGrid")
    .Grid("policyGrid")
    .Delay(500)
    .Placeholder("Enter filter text here"))


    Is there an option I don't see or an event handler I should to use?

    Thanks,
    Eric
  • Marked as Answer

    Replied 16 September 2020, 5:23 pm EST

    Hello Eric,
    We are sorry, we are unable to replicate the issue at our end. Please refer to the attached sample for reference.
    In case the issue persists, please try the following workaround that might help you:
    <script>
    c1.documentReady(function () {
    var search = wijmo.Control.getControl("#theSearch");
    search.hostElement.addEventListener("input", function (e) {
    if (search.text == "") {
    setTimeout(function () {
    search._rxSearch = null;
    search._rxHighlight = null;
    search._view.refresh();
    }, search.delay);
    }
    }, true);
    search.hostElement.addEventListener("mousedown", function (e) {
    if (e.target.tagName == "BUTTON") {
    setTimeout(function () {
    search._rxSearch = null;
    search._rxHighlight = null;
    search._view.refresh();
    }, search.delay);
    }
    },true);
    })
    </script>


    Regards,
    Manish Gupta

    FlexGrid-Search.zip
  • Replied 17 September 2020, 12:26 am EST

    Thanks, Manish. The workaround worked. I added
    search.text = null
    to the mousedown event to get rid of the search text. I will experiment a bit to see if I can track down the root cause. If I find it, I'll post here.

    Thank again,
    Eric.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels