We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Combobox multiple columns

Thread ID:

Created:

Updated:

Platform:

Replies:

141899 Jan 9,2019 09:05 PM UTC Apr 1,2019 08:54 AM UTC ASP.NET MVC - EJ 2 5
loading
Tags: ComboBox
Vanderlei
Asked On January 9, 2019 09:05 PM UTC

Hi,

Using EJ2, VS2017, MVC5...

How to prevent null field values to show like bellow? Couldn't it be shown like an empty space?


I used this code to render it:



Thanks!

Prince Oliver [Syncfusion]
Replied On January 10, 2019 10:57 AM UTC

Hi Vanderlei, 

Thank you for contacting Syncfusion support. 
 
We can use conditional statements in the itemTemplate tot prevent the “null” from being displayed. Kindly refer to the following code snippet. 
 
@Html.EJS().ComboBox("demandaid").DataSource((IEnumerable<object>)ViewBag.data).PopupHeight("500px") 
.Placeholder("Equipemento/item").FloatLabelType(Syncfusion.EJ2.Inputs.FloatLabelType.Always).PopupHeight("270px").Fields(new ComboBoxFieldSettings { Text = "descricao", Value="demandaid" }).ItemTemplate("<span><span class='colunacombobox'>${numdemanda}</span><span class='colunacombobox2'>${descricao}<span class='colunacombobox2'>${marca}</span><span class='colunacombobox2'>${modelo}</span><span class='colunacombobox2'>${numserie}</span>${if(tag)}<span class='colunacombobox2'>${tag}</span>${/if}</span>").Render() 

We have attached a sample for your reference, please find the sample at the following location: http://www.syncfusion.com/downloads/support/forum/141899/ze/MVCSAM~1-1249081287 

Please let us know if you need any further assistance on this. 

Regards, 
Prince 


Vanderlei
Replied On January 10, 2019 01:05 PM UTC

Hi,

Many thanks, it is working...

By the way, isn't there a better way to build the Combobox.ItemTemplate template?

Thank you!

Prince Oliver [Syncfusion]
Replied On January 11, 2019 08:54 AM UTC

Hi Vanderlei, 

Most Welcome. In Template data manipulation when large amount of data is set into ComboBox , we need to check all the data and the entire key value pair using loops and iteration to check whether the data is null or undefined and then set it to the element. So, this will affect the performance. In the provided solution, we have directly used condition to check the value in template itself. Avoiding loops which costs performance, so the suggested method is the better way. Please Let us know if you are facing any issues in this.  

Regards, 
Prince 


Guadalupe
Replied On March 29, 2019 09:51 PM UTC

Hello
We can view to me a example in asp.net webforms with this?

Prince Oliver [Syncfusion]
Replied On April 1, 2019 08:54 AM UTC

Hello Vanderlei, 

Good day to you. 

Yes, we have attached an example in ASP.NET WebForms. Please find the sample at the following location: http://www.syncfusion.com/downloads/support/forum/141899/ze/SyncfusionASPNETApplication3448692343  

Since, we have not provided support for webforms platform in EJ2. We have achieved your requirement by rendering the JavaScript component in webform platform. Kindly refer to the following code snippet. 

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server"> 
    <div class="container" style="margin:20px;"> 
        <input type="text" id="combobox"> 
    </div> 
    <script> 
        var datasource = [{ demandaid: "1", descricao: "Cardioversor", numdemanda: "00003-3", marca: "Philips", modelo: "Cardio", numserie: "5489", tag: "668" }, 
        { demandaid : "2", descricao : "Incubadora", numdemanda : "00005-3", marca : "Siemens", modelo : "AA220", numserie : "162A" }]; 
 
        var comboboxObj = new ej.dropdowns.ComboBox({ 
            placeholder: 'Equipemento/item', 
            dataSource: datasource, 
            itemTemplate: "<span><span class='colunacombobox'>${numdemanda}</span><span class='colunacombobox2'>${descricao}<span class='colunacombobox2'>${marca}</span><span class='colunacombobox2'>${modelo}</span><span class='colunacombobox2'>${numserie}</span>${if(tag)}<span class='colunacombobox2'>${tag}</span>${/if}</span>", 
            fields: { text: 'descricao', value: 'demandaid' }, 
        }); 
        comboboxObj.appendTo('#combobox'); 
    </script> 
    <style> 
        .colunacombobox, 
        .colunacombobox2 { 
            padding: 6px; 
        } 
    </style> 
</asp:Content> 

Let us know if you need any further assistance on this.  

Regards, 
Prince 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;