javascript - Cascading ComboBox drops model binding after setting initial value empty -


my scenario:

cascading dropdowns ending combobox (partial view) used in master->details scenario kendo grid

ddl->ddl->ddl->cb

goal:

  1. on page load dropdownlists being initialized data 1 one default value, , combobox should stay empty
  2. on grid selecteditemchanged partial view being filled data , combobox should display appropriate element.

in case works follows:

  1. on page load combobox displays '0' (null suppose?)
  2. on selection change blinks selected value model.id , shows appropriate text

or if clear text/value propery of kendocombobox when parent dropdownlist data loaded:

  1. on page load combobox empty
  2. on selection change blinks above stays empty

if change combobox control 4th dropdownlist still "blinks" in works fine. selected item model preserved correctly in dropdown.

i cannot provide complete example because it's heavy don't think it's necessary.

this how lists data cascading. on parent's databound event .datasource.read() method of child called. nothing fancy.

function parentproductiddatabound() {     var dropdownlist = $("#parentproductid").data("kendodropdownlist");      if (dropdownlist.value()) {         onparentproductidchange();     } }  function parentproductidchange() {     onparentproductidchange(); }  function onparentproductidchange() {     var productcombobox = $("#productid").data("kendocombobox");     productcombobox.text("");     <- empty until combo populated     productcombobox.value("");     productcombobox.enable(true);  <- enable combo     productcombobox.datasource.read();  <- populate combo } 

and here code of combo itself

@(html.kendo().combobox()               .name("productid")               .datatextfield("text")               .datavaluefield("value")               .autobind(false)               //.text(model.productid == 0 ? " " : model.productname)               .datasource(source =>               {                   source.read(read =>                   {                       read.action("getmeansofproduction", "demandformeansofproduction", new { level = 3 }).data("onproductcomboboxadditionaldata");                   })                         .serverfiltering(false);               })               .events(e =>               {                   e.change("productidchange");                   e.databound("productiddatabound");               })         ) 

it looks like:

  1. whenever combobox not populated displays directly model value binded (id), if model empty -> thats '0' first case - , want wait data
  2. if set value and/or text of combobox empty looses binding model , after populated data doesn't know item should selected...

ideas of solution?

the solution turned out simple it's embarrassing...

i had switch text/value (name/id) pair text/text , there no 'blinking' or disappearance issue more.

turn:

@(html.kendo().combobox()               .name("productid")               .datatextfield("text")               .datavaluefield("value") 

into:

@(html.kendo().combobox()               .name("productname")               .datatextfield("text")               .datavaluefield("text") 

it causes additional work in controller @ least works.

i hope saves time have saved me some...


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -