Filter Grid by remote data from External textbox

  1. #1

    Filter Grid by remote data from External textbox

    Hello masters
    i am using Gridpanel in Mvc .i wanna filter grid via external Textbox and when i click the button under Grid mvc Grab data from external Text box in page and show final result in Grid. i should not use remote filtering on top of column and it must be independent.i dont Know how can i do it.
  2. #2
    Hello @orpheus, and welcome to Ext.NET forums!

    You can just call the grid store's addFilter() passing something like:

    new Ext.util.Filter({
        property: "Company",
        value: document.getElementById('myInputField').value
    });
    And then pass that filter to the grid via something like

    App.MyGrid1.getStore().addFilter(<that_filter_above>);
    So shouldn't be too hard.

    There may also be the need to clear the filter, etc, see more on using the grid filter feature here: ExtJS API documentation on Store Filters.

    You can quickly see a working example if you just open this example: https://examples4.ext.net/Examples/G...ayGrid/Simple/
    Then switch developer tools on, and enter this on console:

    App.GridPanel1.getStore().addFilter(new Ext.util.Filter({property: "company", value: "AT" }));
    If what you need is limited to client-side only, this is maybe the best way to go. There's never a single option, so you don't need to stick to this if you find some way else to attain your objective.

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    hello sir
    very very tanks for reply
    finally i used from directmethod for pass data of textboxes .in this case passing data is correct and "name" and "number" parameter has textbox value but when i click button, grid not reload
    in this controller i wrote this code:
     
    
    [DirectMethod]
            public ActionResult OrderSearch(string name="", int number=0)
            {
                OrderGridVm SearchOrderGridVm=new OrderGridVm(){CompanyName = name,CompanyNumber= number };
                var tempdata = _edOrderService.GetOrderGridVm(SearchOrderGridVm);
                return this.Store(tempdata );
            }
    and in cshtml i wrote this
    @(
               Html.X().FormPanel()
                   .Title("Company Information")
                   .Width(350)
                   .BodyPadding(5)
                   .Frame(true)
                   .Layout(LayoutType.Form)
                   .FormBind(true)
                   .Items(
                       Html.X().TextField().ID("CompanyName").FieldLabel("Company Name") ,
                       Html.X().TextField().ID("CompanyNumber").FieldLabel("Company number").AllowBlank(false) 
                   )
                   .Buttons(
                       Html.X().Button()
                           .Text("Submit")
                           .Icon(Icon.Lightning)
                           .FormBind(true)
                           .Handler("App.direct.OrderSearch(App.CompanyName.getValue(), App.CompanyNumber.getValue());") 
                        
                            
                   )
    )
    in above code for example my grid before filter has 3 record When the filter is applied "tempdata" has only one record but grid Still showing 3 record .if you help me how to reload or replace, "store" for filterd model in serverside my problem is solved.
    Thank you so much.
  4. #4
    Hello, @orpheus!

    In order to be able to help you with that, we'd need to have these code snippets in a way we can copypaste in a project and run them.

    For a MVC, this would require at least the controller code, including Index, and the full view code.

    I think a good sample showing what we would need for a sample with direct method would be in the MVC DirectMethod example in our examples explorer: Events - Direct Method.

    While we are at it, please take your time to review our guidelines on posting new threads and test cases, it really helps us help you:
    - Tips for creating simplified code samples
    - More Information Required
    - Forum Guidelines

    Looking forward to your follow-up!
  5. #5
    Hello
    Thank you for your guidance.your Approach about filter work Properly.its Great but i have still two Question without answer
    1) how can i reload store in grid in server side Because i can do it client side but i need in server side
    2) i have used "Ext.util.Filter" and Almost my problem has been solved but in string I have to type the whole sentence or some character of first of word.
    for example if "Mr.Brown " exists in a Grid's column when i search "Brown" does not return any result but if i search Mr.Br or Mr.Brown it return true result.
    very very thanks for your Help

Similar Threads

  1. Replies: 8
    Last Post: Jun 05, 2016, 8:10 PM
  2. [CLOSED] Nested Grid w/Remote Filter
    By jwhitmire36 in forum 2.x Premium Help
    Replies: 4
    Last Post: Sep 24, 2014, 7:14 PM
  3. [CLOSED] Sorting grid groups based on external data
    By bayoglu in forum 2.x Premium Help
    Replies: 16
    Last Post: May 20, 2013, 6:16 PM
  4. Replies: 1
    Last Post: Apr 10, 2013, 9:27 PM
  5. [CLOSED] Grid Filter from Textbox
    By amitpareek in forum 1.x Premium Help
    Replies: 6
    Last Post: Sep 03, 2009, 9:21 AM

Posting Permissions