[CLOSED] Razor/MVC custom search

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Razor/MVC custom search

    I'm looking to reproduce the example here: https://examples2.ext.net/#/Form/Com...Custom_Search/ in MVC/Razor syntax but I'm having some trouble getting the method to trigger. Can you provide syntax? Is it necessary to use a .ashx file or can you set up a route directly to a controller method?

    thanks
    Last edited by geoffrey.mcgill; Mar 18, 2012 at 2:25 AM. Reason: [CLOSED]
  2. #2
    Hi,

    Quote Originally Posted by machinableed View Post
    I'm looking to reproduce the example here: https://examples2.ext.net/#/Form/Com...Custom_Search/ in MVC/Razor syntax but I'm having some trouble getting the method to trigger. Can you provide syntax?
    Well, we have no such example on Razor.

    Could you provide what you are able to achieve at the moment? Where exactly are facing a problem with syntax?

    Quote Originally Posted by machinableed View Post
    Is it necessary to use a .ashx file or can you set up a route directly to a controller method?
    Sure, you can refererence a controller action setting up a respective Url.
  3. #3
    The issue I'm facing is that I can't get the controller method to trigger when I type in the box. The store and proxy I'm using works in a different example but I'm not sure how t get the combo box to trigger the controller. I can't actually post the code right now as I'm not at work, but I will do ASAP
  4. #4
    Here is the code I've been trying to use:
    cnt.Add(Html.X().FieldContainer()
                                    .Layout(LayoutType.HBox)
                                    .Padding(10)
                                    .Margins("0 0 0 0")
                                    .Items(fields =>
                                    {
                                            fields.Add(Html.X().ComboBox()
                                                .Width(700)
                                                .FieldLabel("Customer/Organisation Name")
                                                .Margins("0 0 4 0")
                                                .LabelWidth(200)
                                                .MinChars(1)
                                                .DisplayField("OrganisationName")
                                                .ValueField("OrganisationName")
                                                .HideBaseTrigger(true)
                                                .TypeAhead(false)
                                                .Cls("form-label")
                                                .ListConfig(Html.X().BoundList()
                                                    .LoadingText("Searching...")
                                                    .Height(200)
                                                    .ItemTpl(Html.X().XTemplate()
                                                        .Html("<div class=\"search-item\"><h3><span>{PartyID}</span>{OrganisationName}</h3>{OrganisationCode}</div>")
                                                    )
                                                )
                                                .Store(store => Html.X().Store()
                                                    .Proxy(proxy => proxy.Add(Html.X().AjaxProxy()
                                                        .Url("/Party/GetOrganisations/")
                                                        .Reader(reader => reader.Add(Html.X().JsonReader()
                                                                .Root("data")
                                                                .TotalProperty("total")
                                                                ))
                                                            ))
                                                    .Model(model => model.Add(Html.X().Model()
                                                        .Fields(modelFields =>
                                                        {
                                                            modelFields.Add(Html.X().ModelField().Name("OrganisationName"));
                                                            modelFields.Add(Html.X().ModelField().Name("OrganisationCode"));
                                                            modelFields.Add(Html.X().ModelField().Name("PartyID"));
                                                        })                                            ))
                                            )
                                        );
                                    })
                                );
    The route to the /
    Party/GetOrganisations method is definitely working as I can bind to other controls and also see the raw JSON if i enter it directly as the URL, but when I try to trigger it using the combobox as a "custom search" box as per the example, the method never gets triggered...
  5. #5
    Please ensure the code is wrapped in [CODE ] tags, see:
    Forum Guidelines For Posting New Topics
  6. #6
    Thanks for the wrapping in [CODE ] tags.

    The problem lays here:
    .Store(store => 
        Html.X().Store()
            ...                                    
    )
    It should be:
    .Store(store =>
        store.Add(Html.X().Store()
            ...
        )
    )
  7. #7
    Thanks it's working now... You can close this topic
  8. #8

    Problem after SVN update

    Hi there,

    I had this functionality working with no problems, but since an SVN update I'm experiencing some strange behaviour. The method in the controller is still firing and obviously returning results as I can see the paging information changing, but the items don't appear in the drop down (the entire drop down is either blank after the initial result displays for a split second initially or the drop down doesnt expand as shown in the screenshot):

    The code I'm using is:
                        containers.Add(Html.X().FieldContainer()
                            .Layout(LayoutType.Anchor)
                            .Margins("0 0 0 0")
                            .Width(900)
                            .Items(cnt =>
                            {
                                cnt.Add(Html.X().FieldContainer()
                                    .Layout(LayoutType.HBox)
                                    .Padding(10)
                                    .Margins("0 0 0 0")
                                    .Items(fields =>
                                    {
                                        fields.Add(Html.X().ComboBox()
                                            .Width(700)
                                            .FieldLabel("Customer/Organisation Name")
                                            .ID("cmbCustomer")
                                            .Margins("0 0 4 0")
                                            .LabelWidth(200)
                                            .PageSize(20)
                                            .Note("Type Organisation Name to search and select an organisation. (*) to show all")
                                            .MinChars(1)
                                            .DisplayField("DisplayName")
                                            .ValueField("PartyID")
                                            .HideBaseTrigger(true)
                                            .TypeAhead(false)
                                            .Cls("form-label")
                                            .ListConfig(Html.X().BoundList()
                                                .LoadingText("Searching...")
                                                .Height(200)
                                                .ItemTpl(Html.X().XTemplate()
                                                    .Html("<div class=\"search-item\"><h3><span>{PartyID}</span>{DisplayName}</h3>{OrganisationCode}</div>")
                                                )
                                            )
                                            .Store(store => store.Add(Html.X().Store()
                                                .Proxy(proxy => proxy.Add(Html.X().AjaxProxy()
                                                    .Url("/Party/GetOrganisations/")
                                                    .Reader(reader => reader.Add(Html.X().JsonReader()
                                                            .Root("data")
                                                            .TotalProperty("total")
                                                            ))
                                                        ))
                                                .Model(model => model.Add(Html.X().Model()
                                                    .Fields(modelFields =>
                                                    {
                                                        modelFields.Add(Html.X().ModelField().Name("DisplayName"));
                                                        modelFields.Add(Html.X().ModelField().Name("OrganisationCode"));
                                                        modelFields.Add(Html.X().ModelField().Name("PartyID"));
                                                    })
                                            ))
                                        ))
                                    );
                                    })
                                );
                            })
                        );
                    })
  9. #9
    I have done a further test by referencing the previous 2.0 beta dll (as released a couple of weeks ago) and this functionality works again - there is definitely something broken in the latest build...
  10. #10
    What is a response of a controller action?

    Could you also provide the code of a controller action to reproduce the problem?
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] [1.0] Custom search help
    By edigital in forum 1.x Legacy Premium Help
    Replies: 11
    Last Post: Apr 10, 2015, 7:44 PM
  2. [CLOSED] Custom Search Combobox
    By vali1993 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 04, 2010, 7:29 PM
  3. [CLOSED] [1.0] custom search
    By vali1993 in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Apr 23, 2010, 3:48 PM
  4. [CLOSED] custom search v1.0 IE6
    By sharif in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Feb 18, 2010, 7:05 PM
  5. Custom Search
    By sharif in forum 1.x Help
    Replies: 0
    Last Post: Jul 14, 2009, 4:04 PM

Posting Permissions