The following code loads a Kendo DropDownList, but while the page renders it first shows the DataValueField prior to the DataTextField. It binds just fine to the DataTextField after a second, but I would not like to show the numeric value while it renders. Does anyone know of a way to make only the DataTextField value be shown and not the DataValueField for that first second while it renders?
@(Html.Kendo().DropDownList()
.Name("SomeName")
.DataTextField("SomeTextField")
.DataValueField("SomeValueField")
.DataSource(source => {
source.Read(read => {
read.Url(Url.ExtensionMethodThatReturnsURL("SomeAction", "SomeController"));
}).ServerFiltering(true);
})
.HtmlAttributes(new { @Class = "some-class" })
.Value(businessKey.ToString())
.Events(e => e.Change("Some.Javascript.onEventHandler"))
.Deferred()
)
The problem is probably caused by the
.Deferred()
statement, which delays the widget initialization until the deferred scripts are rendered viaI assume there is something time consuming taking place between the rendering of the DropDownList textbox and the widget initialization. So you are seeing the numeric value inside the plain non-initialized textbox. I have two suggestions:
DeferredScripts()
call closer to the DropDownList declaration, if possible.For example:
DropDownList and JavaScript
CSS
Contrary to
display:none
, thevisibility:hidden
style will make the DropDownList textbox occupy space on the screen even while hidden, so you will avoid flickering and layout readjustments.