Help with searching all columns in a Flexgrid from an ASP.NET MVC App

Posted by: Victor.m.charles.civ on 7 September 2019, 9:57 am EST

  • Posted 7 September 2019, 9:57 am EST

    Hello,

    I’m using the code below to search all columns in a C1TrueDBGrid (C1AOP5)control for text entered in a text box in my Windows App. How do I modify the code below to achieve the same for a FlexGrid in my ASP.NET MVC App?

    If possible, can you please send me sample application with the solution.

    Code below is activated from the Form Load Event: A datatable “FilteredDTA” is should already available in the ASP.NET App.

    fsLinkAOP5 = New System.IO.FileStream(Application.StartupPath + “\AOPs.xml”, IO.FileMode.Open)

    dtsetLinkAOP5X.Clear()

    dtsetLinkAOP5X.ReadXml(fsLinkAOP5)

    fsLinkAOP5.Close()

    Dim FilteredDTA As DataTable

    FilteredDTA = dtsetLinkAOP5X.Tables(0)

    Dim view5 As DataView

    Dim query5 As String = “”

    query5 = FilteredDTA.Columns(0).ColumnName & “= '” & FormGlobalMain.TextBox1.Text & “'”

    For x = 1 To FilteredDTA.Columns.Count - 1

    query5 &= " OR " & FilteredDTA.Columns(x).ColumnName & “= '” & FormGlobalMain.TextBox1.Text & “'”

    Next

    view5 = New DataView(FilteredDTA)

    view5.RowFilter = query5

    If view5.Count <> 0 Then

    C1AOP5.DataSource = view5

    C1AOP5.Visible = True

    C1AOP5.Splits(0).DisplayColumns(0).Visible = False

    apply = True

    C1AOP5.Refresh()

    For Each cdc As C1DisplayColumn In C1AOP5.Splits(0).DisplayColumns

    cdc.FetchStyle = True

    Next

                                         For i As Integer = 0 To C1AOP5.Columns.Count - 1
                        Dim count As Integer = 0
                        For j As Integer = 0 To C1AOP5.Splits(0).Rows.Count - 1
                            If C1AOP5(j, i).ToString() = "N/A" Or C1AOP (j,i).ToString   () = "" Then
                                count = count + 1
                            End If
                            If count = C1AOP5.Splits(0).Rows.Count Then
                                C1AOP5.Splits(0).DisplayColumns(i).Visible = False
                            End If
                        Next
                    Next
                Else
                C1AOP5.Visible = False
                End If
    

    Thanks,

    Victor

  • Posted 8 September 2019, 10:18 pm EST

    Hi Victor,

    The MVC FlexGrid architecture is based on MS Excel which provides the filtering same as MS Excel. It allows to search in the Columns using ColumnFilter. You may also use the CollectionView.filter method to apply Global filter along with the ColumnFilter.

    Please refer to the following demo sample for reference:

    https://demos.componentone.com/ASPNET/LearnMvcClient/C1Mvc/CVChaining

    More filter demos: https://demos.componentone.com/ASPNET/LearnMvcClient/C1FlexGrid/Filtering

    Hope it helps!

    Regards,

    Manish Gupta

Need extra support?

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

Learn More

Forum Channels