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. Image for the cookie policy date

Combobox multiple columns

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!

5 Replies

PO Prince Oliver Syncfusion Team January 10, 2019 05:57 AM

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 



VA Vanderlei January 10, 2019 08:05 AM

Hi,

Many thanks, it is working...

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

Thank you!


PO Prince Oliver Syncfusion Team January 11, 2019 03:54 AM

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 



GU Guadalupe March 29, 2019 05:51 PM

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


PO Prince Oliver Syncfusion Team April 1, 2019 04:54 AM

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 


Loader.
Live Chat Icon For mobile
Up arrow icon