- Home
- Forum
- ASP.NET MVC - EJ 2
- Combobox multiple columns
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!
SIGN IN To post a reply.
5 Replies
PO
Prince Oliver
Syncfusion Team
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
VA
Vanderlei
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!
PO
Prince Oliver
Syncfusion Team
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
GU
Guadalupe
March 29, 2019 09:51 PM UTC
Hello
We can view to me a example in asp.net webforms with this?
PO
Prince Oliver
Syncfusion Team
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
SIGN IN To post a reply.
- 5 Replies
- 3 Participants
-
VA Vanderlei
- Jan 9, 2019 09:05 PM UTC
- Apr 1, 2019 08:54 AM UTC