[OPEN] [#1622] [4.7.1] assign Store to MultiSelectorSearch of MultiSelector

Page 1 of 2 12 LastLast
  1. #1

    [OPEN] [#1622] [4.7.1] assign Store to MultiSelectorSearch of MultiSelector

    Hello

    i want to Use a component that can select multi item and user can search between all items in model i found MultiSelector in Webform(aspx) but i cant Find any sample in mvc.
    with this code store loaded in MultiSelector
               Html.X().MultiSelector().Width(300).Height(200) 
                 .FieldName("Title").MultiSelect(true).AutoScroll(true)
                  .AllowDeselect(true).Selectable(true)
                  .Store( Html.X().Store().ID("RoleStore")
                  .DataSource(Model)
                   .Model(
                    Html.X().Model()
                    .Fields(
                    new ModelField("Title", ModelFieldType.String)
                           )
                         )     
                        ).Search(Html.X().MultiSelectorSearch().Store(Html.X().Store().ID("RoleStore")
                      .DataSource(Model)
                      .Model(
                      Html.X().Model()
                      .Fields(
                      new ModelField("Title", ModelFieldType.String)
                                                   )
                                           ) 
                                      )
               
                            )
    but when i want assign store to MultiSelectorSearch i get error like this

    cannot convert from 'Ext.Net.Store.Builder' to 'System.Action<Ext.Net.StoreCollection<Ext.Net.Sto re>>
    how can i assign Store to MultiSelectorSearch
    Last edited by fabricio.murta; Jan 17, 2019 at 1:15 PM.
  2. #2
    Hello @orpheus!

    You can assign a store to any component having a store the same way you would do to a GridPanel.

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Hello FabrÃ*cio
    Thank you very much for reply But i tried this way.but As i understood multiselectorSearch is only tools that get StoreCollection.you suggest me looking Grid Sample but it need to set StoreCollection not Store.if you see my Code i assign store to MultiSelector like grid but when i want assign Store with the same way to multiselectorSearch i get error that i wrote in first post.
    I think multiSelector is very Useful and Interesting tool because it can helps in "many to many" relationship but it is without example in mvc.
    Please see my code again.I assign store to grid and chart and other tools but multiselectorSearch does not follow that methods Or maybe I'm wrong.
    In fact, the following section works correctly
        Html.X().MultiSelector().Width(300).Height(200) 
                 .FieldName("Title").MultiSelect(true).AutoScroll(true)
                  .AllowDeselect(true).Selectable(true)
                  .Store( Html.X().Store().ID("RoleStore")
                  .DataSource(Model)
                   .Model(
                    Html.X().Model()
                    .Fields(
                    new ModelField("Title", ModelFieldType.String)
                           )
                         )     
                        )
    but when i add following section to end of Previous code i get error(it say i need StoreCollection not Store)
    .Search(Html.X().MultiSelectorSearch().Store(Html.X().Store().ID("RoleStore")
                      .DataSource(Model)
                      .Model(
                      Html.X().Model()
                      .Fields(
                      new ModelField("Title", ModelFieldType.String)
                                )
                                ) 
               )
    thanks a lot.
    Last edited by orpheus; Jan 15, 2019 at 4:15 PM.
  4. #4
    Hello, @orpheus!

    Sorry if the last reply didn't help much. Please make a runnable test case so we can reproduce the issue in our side and better advice you how to proceed.
    Fabrício Murta
    Developer & Support Expert
  5. #5
    Hello FabrÃ*cio
    i attach controller and view and Model because fourum does not permit rar and zip file.it is very simple test That displays my problem.

    multiSelector is very Interesting tools I hope I can use it.

    thank you very much

    Controller

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using UseMultiSearch.Models;
    
    namespace UseMultiSearch.Controllers
    {
        public class HomeController : Controller
        {
       
            public ActionResult Index()
            {
                return View("Index",Companies.GetAllCompanies());
            }
        }
    }
    View

    @model System.Collections.IEnumerable
    @using System.Web.Mvc
    @using Ext.Net
    @using Ext.Net.MVC
    @{
        ViewBag.Title = "Index";
    }
    
    <h2>Index</h2>
    
    @Html.X().ResourceManager()
    
    @(
    
    
            Html.X().MultiSelector().Width(300).Height(200).FieldName("Title").MultiSelect(true).AutoScroll(true).AllowDeselect(true).Selectable(true)
                .Store(Html.X().Store().ID("RoleStore")
                    .DataSource(Model)
                    .Model(
                        Html.X().Model()
                            .Fields(
                                new ModelField("Title", ModelFieldType.String)
                            )
                    )
    
                )
            //------------------------------------------ without this section MultiSelector work properly but I really need to Search Items
                      .Search(Html.X().MultiSelectorSearch().Store(Html.X().Store().ID("RoleStore")
                          .DataSource(Model)
                          .Model(
                              Html.X().Model()
                                  .Fields(
                                      new ModelField("Title", ModelFieldType.String)
                                  )
                          )
                          )
    
    
    
    
          )
          //----------------------------------------------
          )
    Model

    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    
    namespace UseMultiSearch.Models
    {
        public class Companies
        {
            public static IEnumerable GetAllCompanies()
            {
                return new object[]
                    {
                        new object[] { "3m Co", 71.72, 0.02, 0.03, "9/1 12:00am" },
                        new object[] { "Alcoa Inc", 29.01, 0.42, 1.47, "9/1 12:00am" },
                        new object[] { "Altria Group Inc", 83.81, 0.28, 0.34, "9/1 12:00am" },
                        new object[] { "American Express Company", 52.55, 0.01, 0.02, "9/1 12:00am" },
                        new object[] { "American International Group, Inc.", 64.13, 0.31, 0.49, "9/1 12:00am" },
                        new object[] { "AT&T Inc.", 31.61, -0.48, -1.54, "9/1 12:00am" },
                        new object[] { "Boeing Co.", 75.43, 0.53, 0.71, "9/1 12:00am" },
                        new object[] { "Caterpillar Inc.", 67.27, 0.92, 1.39, "9/1 12:00am" },
                        new object[] { "Citigroup, Inc.", 49.37, 0.02, 0.04, "9/1 12:00am" },
                        new object[] { "E.I. du Pont de Nemours and Company", 40.48, 0.51, 1.28, "9/1 12:00am" },
                        new object[] { "Exxon Mobil Corp", 68.1, -0.43, -0.64, "9/1 12:00am" },
                        new object[] { "General Electric Company", 34.14, -0.08, -0.23, "9/1 12:00am" },
                        new object[] { "General Motors Corporation", 30.27, 1.09, 3.74, "9/1 12:00am" },
                        new object[] { "Hewlett-Packard Co.", 36.53, -0.03, -0.08, "9/1 12:00am" },
                        new object[] { "Honeywell Intl Inc", 38.77, 0.05, 0.13, "9/1 12:00am" },
                        new object[] { "Intel Corporation", 19.88, 0.31, 1.58, "9/1 12:00am" },
                        new object[] { "International Business Machines", 81.41, 0.44, 0.54, "9/1 12:00am" },
                        new object[] { "Johnson & Johnson", 64.72, 0.06, 0.09, "9/1 12:00am" },
                        new object[] { "JP Morgan & Chase & Co", 45.73, 0.07, 0.15, "9/1 12:00am" },
                        new object[] { "McDonald\"s Corporation", 36.76, 0.86, 2.40, "9/1 12:00am" },
                        new object[] { "Merck & Co., Inc.", 40.96, 0.41, 1.01, "9/1 12:00am" },
                        new object[] { "Microsoft Corporation", 25.84, 0.14, 0.54, "9/1 12:00am" },
                        new object[] { "Pfizer Inc", 27.96, 0.4, 1.45, "9/1 12:00am" },
                        new object[] { "The Coca-Cola Company", 45.07, 0.26, 0.58, "9/1 12:00am" },
                        new object[] { "The Home Depot, Inc.", 34.64, 0.35, 1.02, "9/1 12:00am" },
                        new object[] { "The Procter & Gamble Company", 61.91, 0.01, 0.02, "9/1 12:00am" },
                        new object[] { "United Technologies Corporation", 63.26, 0.55, 0.88, "9/1 12:00am" },
                        new object[] { "Verizon Communications", 35.57, 0.39, 1.11, "9/1 12:00am" },
                        new object[] { "Wal-Mart Stores, Inc.", 45.45, 0.73, 1.63, "9/1 12:00am" }
                    };
            }
        }
    }
    Last edited by fabricio.murta; Jan 15, 2019 at 8:02 PM.
  6. #6
    Please attach the samples under [code][/code] blocks.

    I will try to adapt your post to fit the guidelines.

    - Tips for creating simplified code samples
    - More Information Required
    - Forum Guidelines

    I understand it is a lot to read but that would help a lot for us and other people to be able to help you in the future.
    Fabrício Murta
    Developer & Support Expert
  7. #7
    ok Excuse me.I am newcomer and I'll pay more attention.this pic display my problem ClearerClick image for larger version. 

Name:	Multis2.png 
Views:	46 
Size:	41.0 KB 
ID:	25221
  8. #8
    Hello again, @orpheus!

    Your usage almost completely looks right; only detail on that is that you assigned the same ID to both stores. Although they share the same data they shouldn't share the same ID (whenever that's the case, a store reference should be used instead of a new store definition).

    But still, there's something wrong with the Razor build syntax, it really seems to have a problem. I will double check whether that's a bug and file an issue if so; will post an update here as soon as we have news about it.
    Fabrício Murta
    Developer & Support Expert
  9. #9
    Hello FabrÃ*cio
    I will wait because I am interested in this tool. I hope I can use it.I think it would be very useful for other developers too.
    Thank you for your time and consideration
  10. #10
    Hello again @orpheus!

    This is not really a defect, but a missing feature. To often-used components, we implement syntax sugar to allow specifying a component directly in MVC Razor syntax.

    It is just the case that both .Search() and .Store() on the Multiselector component and its MultiselectorSearch subcomponent are not implemented.

    That way, you should replace whatever you do like:

    .Store(Html.X().Store())
    to

    .Store((store) => { store.Add(Html.X().Store()); })
    That said, your view just has to be changed to this:

    @model System.Collections.IEnumerable
    @{
        ViewBag.Title = "Index";
    }
    
    <!DOCTYPE html>
    <html>
    <head>
        <title>Index</title>
    </head>
    <body>
        <div>
            <h2>Index</h2>
    
            @Html.X().ResourceManager()
    
            @(
                Html.X().MultiSelector()
                    .Width(300)
                    .Height(200)
                    .FieldName("Title")
                    .MultiSelect(true)
                    .AutoScroll(true)
                    .AllowDeselect(true)
                    .Selectable(true)
                    .Store(
                        Html.X().Store().ID("RoleStore")
                            .DataSource(Model)
                            .Model(
                                Html.X().Model()
                                    .Fields(
                                        new ModelField("Title", ModelFieldType.String)
                                    )
                            )
                    )
                    .Search((searchcomp) =>
                    {
                        searchcomp.Add(
                            Html.X().MultiSelectorSearch()
                                .SearchGridConfig(Html.X().GridPanel().BufferedRenderer(false))
                                .Store((store) =>
                                {
                                    store.Add(
                                        Html.X().Store()
                                            .ID("RoleStore2")
                                            .DataSource(Model)
                                            .Model(
                                                Html.X().Model()
                                                    .Fields(
                                                        new ModelField("Title", ModelFieldType.String)
                                                    )
                                            )
                                    );
                                })
                        );
                    })
            )
        </div>
    </body>
    </html>
    We've logged a feature issue after #1622 to track and implement it the next Ext.NET versions.

    Well, now you should be able to use it with the correct syntax. Hope this helps! This usually is the case every time you miss the simpler MVC Razor syntax, just use the lambda-style Add() call.
    Fabrício Murta
    Developer & Support Expert
Page 1 of 2 12 LastLast

Similar Threads

  1. Multiselector Clear and DataBind.
    By oespiao in forum 4.x Help
    Replies: 1
    Last Post: Mar 01, 2017, 12:20 PM
  2. How to assign store.
    By massman07 in forum 2.x Help
    Replies: 7
    Last Post: Jul 15, 2014, 11:10 AM
  3. [CLOSED] Error when assign datasource to store in user control
    By redi in forum 2.x Legacy Premium Help
    Replies: 8
    Last Post: Dec 18, 2013, 1:59 AM
  4. Replies: 1
    Last Post: Jun 18, 2013, 3:56 PM
  5. [CLOSED] assign collection to store on the client
    By LeeTheGreek in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 23, 2010, 6:46 PM

Posting Permissions