Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
0
Igcombo
posted

If there is only one data in igcombo how we can automatically select it, when combo in loaded.

  • 20
    Offline posted
    Hello Gopi,

    Thank you for posting in our community.

    You can use our index method. Have a look at the code snippet below.
    Also it may be helpful to take a look at this post.


    <!DOCTYPE html>
    <html>
      <head>
        <title></title>
        <link
          href="http://cdn-na.infragistics.com/igniteui/2019.1/latest/css/themes/infragistics/infragistics.theme.css"
          rel="stylesheet"
        />
        <link
          href="http://cdn-na.infragistics.com/igniteui/2019.1/latest/css/structure/infragistics.css"
          rel="stylesheet"
        />
        <script src="http://ajax.aspnetcdn.com/ajax/modernizr/modernizr-2.8.3.js"></script>
        <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
        <script src="http://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>
        <script src="http://cdn-na.infragistics.com/igniteui/2019.1/latest/js/infragistics.core.js"></script>
        <script src="http://cdn-na.infragistics.com/igniteui/2019.1/latest/js/infragistics.lob.js"></script>
      </head>
      <body>
        <h3>
          Automatic selection
        </h3>
        <div id="combo"></div>
    
        <script>
          var northwindProducts = [
            // { ProductID: 1, ProductName: "Chai" },
            // { ProductID: 2, ProductName: "Chang" },
            // { ProductID: 3, ProductName: "Aniseed Syrup" },
            // { ProductID: 4, ProductName: "Chef Anton\u0027s Cajun Seasoning" },
            // { ProductID: 5, ProductName: "Chef Anton\u0027s Gumbo Mix" },
            // { ProductID: 6, ProductName: "Grandma\u0027s Boysenberry Spread" },
            // { ProductID: 7, ProductName: "Uncle Bob\u0027s Organic Dried Pears" },
            // { ProductID: 8, ProductName: "Northwoods Cranberry Sauce" },
            // { ProductID: 9, ProductName: "Mishi Kobe Niku" },
            // { ProductID: 10, ProductName: "Ikura" },
            // { ProductID: 12, ProductName: "Queso Manchego La Pastora" },
            // { ProductID: 13, ProductName: "Konbu" },
            // { ProductID: 14, ProductName: "Tofu" },
            // { ProductID: 15, ProductName: "Genen Shouyu" },
            // { ProductID: 16, ProductName: "Pavlova" },
            // { ProductID: 17, ProductName: "Alice Mutton" },
            // { ProductID: 18, ProductName: "Carnarvon Tigers" },
            // { ProductID: 19, ProductName: "Teatime Chocolate Biscuits" },
            // { ProductID: 20, ProductName: "Sir Rodney\u0027s Marmalade" },
            // { ProductID: 21, ProductName: "Sir Rodney\u0027s Scones" },
            // { ProductID: 22, ProductName: "Gustaf\u0027s Knäckebröd" },
            // { ProductID: 23, ProductName: "Tunnbröd" },
            // { ProductID: 24, ProductName: "Guaraná Fantástica" },
            // { ProductID: 25, ProductName: "NuNuCa Nuß-Nougat-Creme" },
            // { ProductID: 26, ProductName: "Gumbär Gummibärchen" },
            // { ProductID: 27, ProductName: "Schoggi Schokolade" },
            // { ProductID: 28, ProductName: "Rössle Sauerkraut" },
            // { ProductID: 29, ProductName: "Thüringer Rostbratwurst" },
            { ProductID: 30, ProductName: "Nord-Ost Matjeshering" }
          ];
    
          $(function() {
            $("#combo").igCombo({
              width: "470px",
              dataSource: northwindProducts,
              textKey: "ProductName",
              valueKey: "ProductID",
              filteringType: "local"
            });
            if (northwindProducts.length == 1) $("#combo").igCombo("index", 0);
          });
        </script>
      </body>
    </html>
    


    Let me know if I may be of further assistance.

    Kind regards,
    Martin