EXT.NET MVC GridPanel filter's comboBox's Listerners error

  1. #1

    EXT.NET MVC GridPanel filter's comboBox's Listerners error

    I have a big problem with my GridPanel filter's comboBox's from EXT.NET MVC.

    I've added listeners to my columns comboBoxes for date and number types columns and it works very well but when I try to use listeners for text type column with a combobox as column filter it said : You can't use lambda expression for an operation done dynamically you must cast as delegate or as expression trees... something like that (Actually i'm french I can't translate this error properly) I don't understad this error and why I can't use lambda expression for this Listerners while I can use it for the other types.

    Can you help me to find out a solution? Thank you :)

    Here's the PartialView code :

    @Html.X().ResourceManager().RenderStyles(ResourceLocationType.Embedded).Theme(Theme.Gray)
    @(
        Html.X().GridPanel()
                            .Title("GridRtv")
                            .ID("GridRtv")
                            .Layout(LayoutType.Auto)
                            .Height(400)                       
                            .AutoScroll(true)
                            .AutoShow(true)
                            .Store(Html.X().Store()
                                    .ID("StoreRtv")
                                    .Model(Html.X().Model()
                                        .Fields(
                                            new ModelField("RTV_DL", ModelFieldType.Date),
                                            new ModelField("RTV_TR", ModelFieldType.String),
                                            new ModelField("RTV_NF", ModelFieldType.String)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
                                            )
                                        )
                                        .DataSource(@ViewBag.ListeLV)
                                    )                   
                            .ColumnModel(
                                Html.X().DateColumn()
                                    .Text("Date création")                                    
                                    .DataIndex("RTV_DL")
                                    .Format("dd/MM/yyyy")                                    
                                    .Items(
                                        Html.X().DateField()
                                            .ID("RTV_DLFilter")
                                            .Editable(false)
                                            .Listeners(l =>
                                            {
                                                l.Change.Handler = "applyFilter(this);";
                                            })
                                            .Plugins(Html.X().ClearButton())
                                    ),
    
                                Html.X().Column()
                                    .Text("Type R")
                                    .DataIndex("RTV_TR")                                   
                                    .Items(
                                        Html.X().ComboBox()
                                            .ID("ComboBoxRTV_TR")
                                            .Icon(Icon.Magnifier)
                                            .TriggerAction(TriggerAction.All)
                                            .QueryMode(DataLoadMode.Default)
                                            .DisplayField("RTV_TR")
                                            .ValueField("RTV_TR")
                                            .Store(
                                                Html.X().Store()
                                                    .DataSource(@ViewBag.ListeLV)
                                                    .Model(Html.X().Model()
                                                        .Fields(
                                                            Html.X().ModelField().Name("RTV_TR")
                                                        )
                                                    )
                                            )
                                             /**HERE'S THE PROBLEM**/                                                                                                   
                                            .Listeners(l =>
                                            {
                                                l.Change.Handler = "applyFilter(this);";
                                                l.Change.Buffer = 250;
                                            })
                                            /****/                                                                                 
                                            .Plugins(Html.X().ClearButton())
                                ),               
    
                                Html.X().Column()
                                    .Text("Code F")
                                    .DataIndex("RTV_NF")                                    
                                    .Renderer(RendererFormat.Round)
                                    .Items(
                                        Html.X().TextField()
                                            .ID("RTV_NFFilter")
                                            .Listeners(l =>
                                            {
                                                l.Change.Handler = "applyFilter(this);";
                                                l.Change.Buffer = 250;
                                            })
                                            .Plugins(Html.X().ClearButton())
                                    )
           )
           .SelectionModel(
            Html.X().CheckboxSelectionModel()
                .Mode(SelectionMode.Multi)
                )
    )
  2. #2
    Hello @zasif, and welcome to Ext.NET forums!

    The problem is with the DataSource() line you are using. Do you have a special reason to be using it as @ViewBag.ListeLV?

    Maybe what you want is to use it with a proxy to load the data from an action, like the ComboBox with Templates and AJAX example?
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Hello @fabricio.murta,

    Actually I use this example : GridPanel MultiHeader/Filter/

    In my @ViewBag.ListeLV I've all my data that's why I wanted to use DataSource() directly. But now thanks to your help I try with a proxy to load the data from an action but I've 2 problems now. I can't handle duplicates data on the combobox and the combobox doesn't trigger after the first query...

    In my field called RTV_TR I've 4 datas : "AAA", "BBB", "CCC", "AAA" then when I type "A" it shows me 2 line of "AAA" then if I type random character it'd not trigger and then if I try again with "A" it'd not trigger neither, I can't create one action for one field because I've more than 30 fields to handle.

    That's my work :

     Html.X().Column()
                                    .Text("Type retour")
                                    .DataIndex("RTV_TR")                                   
                                    .Items(
                                        Html.X().ComboBox()
                                            .ID("ComboBoxRTV_TR")
                                            .Icon(Icon.Magnifier)
                                            .TypeAhead(false)
                                            .HideTrigger(true)
                                            //.Width(500)
                                            .MinChars(0)
                                            .TriggerAction(TriggerAction.Query)
                                            .QueryMode(DataLoadMode.Default)
                                            .DisplayField("RTV_TR")
                                            .ValueField("RTV_TR")
                                            .ListConfig(Html.X().BoundList()
                                                                .LoadingText("Searching...")
                                                                .ItemTpl(Html.X().XTemplate()
                                                                .Html(@<text>
                                                                        <div class="search-item">
    							                                            {RTV_TR}
    						                                            </div>
                                                                    </text>)
                                                                )
                                                            )
                                            .Store(Html.X().Store()
                                                            .AutoLoad(false)
                                                            .Proxy(Html.X().AjaxProxy()
                                                                .Url(Url.Action("GetRtv"))                                                            
                                                                .ActionMethods(am => am.Read = HttpMethod.POST)
                                                                .Reader(Html.X().JsonReader().RootProperty("data"))
                                                            )
                                                            .Model(Html.X().Model()
                                                            .Fields(
                                                                Html.X().ModelField().Name("RTV_TR")
                                                            )
                                                        )  
                                            )                                                                                                                                            
                                            .Listeners(l =>
                                            {
                                                l.Change.Handler = "applyFilter(this);";
                                                l.Change.Buffer = 250;
                                            })                                                                                 
                                            .Plugins(Html.X().ClearButton())
                                )
    and my controller :

    public ActionResult GetRtv()
    {
          var rtvList = TempData["ListLvRtv"];
    
          return this.Store(rtvList);
    }
    Can you help me to make it work perfectly please? :) Thank you very much
  4. #4
    I can help you! Sure!.. Well.. But you might help me in the other hand: help me help you!

    I mean... You are not supposed to have two same entries in a combo box, there's no way to choose between two entries if they are the same...

    I'm not sure, then, what you meant with that. You really mean you have to support two same entries in the combo box?

    If not, I believe you have just to pre-process the rtvList in your action: either by removing duplicates or by aggregating a differentiating text to duplicate entries (maybe merging with another field, for example).

    Given your example of { "AAA", "BBB", "CCC", "AAA" }, one of those:
    { "AAA", "BBB", "CCC" } (remove stray duplicates)
    { "AAA (marketing)", "BBB", "CCC", "AAA (human resources)" } (conditional appending -- or just append to every entry for conformity).

    I hope this helps. If my reply is off, please try to clarify your example, because I really can't see a combo box working with two exact same entries -- that's not something it was designed to work for.
    Fabrício Murta
    Developer & Support Expert
  5. #5
    Thank you for your reply.

    rtvList contains a table with multiple fields (above 30 fields)... I need a GridPanel which will manage all of these fields. I want to know if it's possible for me to use this rtvList like that : rtvList.Field1, rtvList.Field2, ...

    How can I handle that with my combobox?
  6. #6
    Okay, maybe this example sheds you some light:

    One to Many Data Relationship with GridPanels

    In other words, you want to choose one entry from the ComboBox and then have the entry's details displayed in a grid on the screen, right?

    Like the example above, but instead of choosing the entry from a grid, chosing it from a combo box.
    Fabrício Murta
    Developer & Support Expert
  7. #7
    Thank you for the example,

    In fact I want to have a multiheader gridpanel. My problem is that the whole data for this gridpanel is in a List<data>. I need to get every string field to be like Company field in this example : GridPanel_MultiHeader/Filter so without duplicates for each field.

    I don't know how to do that
  8. #8
    Okay, then I believe we should start talking in examples, it is still not clear to me.

    Do you think you can make it to adapt the MultiHeader example to match your scenario the most and point what you wanted to happen in it that is not actually coming true?..

    I mean, provide a mock controller + view (like you can see in the source of the GridPanel_MultiHeader/Filter example) with a few lines of static data in the format you'll be using on your model/controller. You should be able to provide a code much like the one in the example's sources with data more resembilng your own.

    And then you may attach a screen shot with the grid and point what you are not being able to build in it.

    Once I can run your example here and know exactly what's left to make it work, I can more precisely point you into the right direction.
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Replies: 9
    Last Post: Aug 11, 2015, 11:52 AM
  2. Replies: 4
    Last Post: May 16, 2012, 8:14 AM
  3. Replies: 1
    Last Post: May 11, 2012, 3:46 AM
  4. [CLOSED] Listerners: Definition
    By RomualdAwessou in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 09, 2010, 9:38 PM
  5. [GridPanel] Filter error when date is null
    By knoll in forum 1.x Help
    Replies: 3
    Last Post: Apr 22, 2009, 7:20 AM

Tags for this Thread

Posting Permissions