[CLOSED] ComboBox have two fields in display

  1. #1

    [CLOSED] ComboBox have two fields in display

    For a combo box:
    X.ComboBoxFor(m => m.GLOBAL_TAX_CODE).FieldLabel("Tax Code").LabelWidth(80).DisplayField("ComboDisplay").ValueField("TaxCodeID")
            .ListConfig(Html.X().BoundList()
                            .ItemTpl(Html.X().XTemplate()
                                .Html(@<text>
                                <div class="list-item">
                                    <h3>{Name} - Rate: {RATE}%</h3>   
                                    {DESCRIPTION}                                                                                                   
                                </div>
                                </text>)
                                )
                        )
            .Store(X.Store()
            .ID("TaxCodeComboStore")
            .AutoLoad(true)
            .Model(
                    X.Model()
                    .Name("TaxCodeCombo")
                    .IDProperty("TaxCodeID")
                    .Fields(
                        X.ModelField()
                            .Name("Name")
                            .Type(ModelFieldType.String),
                        X.ModelField()
                            .Name("DESCRIPTION")
                            .Type(ModelFieldType.String),
                        X.ModelField()
                            .Name("RATE")
                            .Type(ModelFieldType.Float)
                    )
                )
            .Proxy(Html.X().AjaxProxy()
                .Url(Url.Action("GetList", "List", new { area = "TaxCode" }))
                .Reader(Html.X().JsonReader().Root("data"))
                )
            )
    can I have a DisplayField setting displaying two model fields instead only one?

    Thank you
    Last edited by Daniil; Apr 02, 2015 at 11:38 AM. Reason: [CLOSED]
  2. #2
    Hi @registrator,

    I guess you need to use a ComboBox's DisplayTpl.

    A possible value could be:
    <tpl for=".">
        {Name} - Rate: {RATE}
    </tpl>
  3. #3
    How would this look like for the MVC razor view please?

    Thnx
  4. #4
    It would look similar to what you defined for .ItemTpl.
  5. #5
    I have removed the Display Field definition and added the diplay template but when clicking and selecting a value fromt he combo nothing is displayed in the field.

    X.ComboBoxFor(m => m.GLOBAL_TAX_CODE).FieldLabel("Tax Code").LabelWidth(80).ValueField("TaxCodeID")
    		.AllowBlank(true)
    		.ListConfig(Html.X().BoundList()
    					.ItemTpl(Html.X().XTemplate()
    						.Html(@<text>
    						<div class="list-item">
    							<h3>{Name} - Rate: {RATE}%</h3>   
    							{DESCRIPTION}                                                                                                   
    						</div>
    						</text>)
    						)
    				)
    		.DisplayTpl(Html.X().XTemplate()
    						.Html(@<text>
    							{Name} {RATE}                                                                                                    
    						</text>)
    		)
    		.Store(X.Store()
    		.ID("TaxCodeComboStore")
    		.AutoLoad(true)
    		.Model(
    				X.Model()
    				.Name("TaxCodeCombo")
    				.IDProperty("TaxCodeID")
    				.Fields(
    					X.ModelField()
    						.Name("Name")
    						.Type(ModelFieldType.String),
    					X.ModelField()
    						.Name("DESCRIPTION")
    						.Type(ModelFieldType.String),
    					X.ModelField()
    						.Name("RATE")
    						.Type(ModelFieldType.Float)
    				)
    			)
    		.Proxy(Html.X().AjaxProxy()
    			.Url(Url.Action("GetList", "List", new { area = "TaxCode" }))
    			.Reader(Html.X().JsonReader().Root("data"))
    			)
    		)
  6. #6
    There must be a <tpl for="."> as it is in my example.
  7. #7
    OK. Very good. Thank you

    .DisplayTpl(Html.X().XTemplate()
                            .Html(@<text>
                                 <tpl for=".">
                                        {Name} - Rate: {RATE}
                                  </tpl>                                                                                                   
                             </text>)
                     )

Similar Threads

  1. [CLOSED] Problem display grid with scroll and other fields
    By matrixwebtech in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 03, 2014, 12:53 PM
  2. Display combine fields in gridpanel
    By Vaishali in forum 1.x Help
    Replies: 3
    Last Post: Feb 06, 2012, 3:39 AM
  3. Replies: 0
    Last Post: Oct 27, 2011, 10:02 PM
  4. Combobox DisplayField 2 fields???
    By 78fede78 in forum 1.x Help
    Replies: 3
    Last Post: Sep 06, 2010, 2:07 PM
  5. Display problem with disabled fields
    By Stefanaccio in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Aug 27, 2010, 6:14 PM

Posting Permissions