Kendo自动完成默认值

时间:2015-07-02 20:03:21

标签: javascript jquery model-view-controller autocomplete kendo-ui

需要已设置值

我正在使用Kendo自动完成功能从列表中选择一个项目。我需要设置文本输入字段的值,并使其实际使用列表中的值。

现在我将输入字段的文本值设置为表中项目的值,尽管它实际上并没有使用它,就像你输入它并单击自动完成的项目一样。 / p>

设置默认文字:

//90-a2-da-0f-25-E7
byte mac[] = {0x90, 0xA2, 0xDA, 0x0f, 0x25, 0xE7};

//ip Address for shield
byte ip[] = {192,168,1,113};

//Use port 23
EthernetServer server = EthernetServer(23);

void setup() {
  //init device
  Ethernet.begin(mac,ip);
  //start listening for clients
  server.begin();

  Serial.begin(9600);     //For visual feedback on what's going on
  while(!Serial){
    ;   //cause Leonardo
  }
  delay(1000);
  if(server.available()){
  Serial.write("Client available");
}
}

void loop() {
  // put your main code here, to run repeatedly:
  EthernetClient client = server.available();
    if (client == true){
      Serial.write("Client Connected.");

      if(client.read() > 0){
        Serial.write(client.read());        
      }
      else{
        server.write("ping");
      }
    }
    else{
      Serial.println("No one's here yet...");
    }
    delay(1500);
}

设置文本框的值:

IQueryable<StorageLocation> query = (from s in db.StorageLocations.Include("StorageLocationType") select s);
        DefaultStorageLocation = query.Count() != 1 ? "" : query.FirstOrDefault().TitleWithType;

我的剑道自动完成:

<input type="text" value="<%: Model.DefaultStorageLocation %>" name="StorageLocation" id="StorageLocation" originalname="StorageLocation" placeholder="" class="autoComplete" style="width: 158px;" />

简而言之。

  • 我正在设置文字输入值
  • 需要它实际使用该值,就好像它是从自动完成中选择的那样

2 个答案:

答案 0 :(得分:0)

看起来你只想在一个值时自动选择第一个值。我认为suggest属性可以满足您的需求:http://docs.telerik.com/kendo-ui/api/javascript/ui/autocomplete#configuration-suggest

或者,尝试value方法:http://docs.telerik.com/kendo-ui/api/javascript/ui/autocomplete#methods-value

答案 1 :(得分:0)

控制器 searchResult 搜索查询

storageLocation = (DefaultWarehouseForIA && !StorageLocation.IsNull()) ? StorageLocation.TitleWithType : "",
defaultStorageLocationID = (DefaultWarehouseForIA && DefaultStorageLocationID.ToLong() > 0) ? DefaultStorageLocationID : null

在填写另一个文本字段时填充JS值。

select: function (e) {
    var dataItem = this.dataItem(e.item.index());
    $('#StorageLocation' + rowID).val(dataItem.storageLocation);
    $('#StorageLocationID' + rowID).val(dataItem.defaultStorageLocationID);
}

此时我已经弄明白了。让它工作。

现在,当填写另一个文本字段时,该值将自动填充。 解释在这里并不太好。但是嘿。

相关问题