简体   繁体   中英

Update all grid dropdown list items on button click

I have a KendoUI grid. I want to add a little button icon thing to the column or edit template that when clicked would set all other dropdown menus on the current page to the selection made in that cell ONLY IF they haven't been set yet.

On click of the icon I need to cycle thru the other DDL's if the value = 1 then set to the value of the DDL beside the icon that was clicked.

If someone could point me in the right direction I would be most appreciative.

网格样本

In your Editor template add events e.select

@(Html.Kendo().DropDownList()
    .Events(e => e.Select("setAllDropDownlist"))
    .DataSource(source => ...)  

)

** * ** * ** * **** javascript function * ** * ***

function setAllDropDownlist(e)
 { 
     var SelectedValue= this.dataItem(e.item.index()).ReasonName

     //loop on all the dropdownlist and check value but I don't recommend doing it
      $("select option").each(function() {
          if($(this).val() == SelectedValue) {
              $(this).attr('selected', 'selected');            
            }


       });  

    //loop one by one on each drop dropdownlist you want to set value

     $("#HowYouKnow option").each(function() {
     if($(this).text() == SelectedText) {
     $(this).attr('selected', 'selected');            
          }                        
    });


  }

Regards

Shaz

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM