问题描述
如果有办法在 Telerik UI for Asp.Net MVC 的“可选”列表框中获取“突出显示”选项,我正在尝试找到它。我知道单击选项列表框中的项目会触发列表框的“onChange”事件,但我不知道如何获取突出显示项目的实际值。
在上面的示例中,我希望返回 Thomas Hardy 和 Christina Berglund,或者至少返回他们的选项 ID。
这是我的列表框定义:
@(Html.Kendo().ListBox()
.Name("optional")
.Toolbar(toolbar =>
{
toolbar.Position(Kendo.Mvc.UI.Fluent.ListBoxToolbarPosition.Right);
toolbar.Tools(tools => tools
.MoveUp()
.MoveDown()
.TransferTo()
.TransferFrom()
.TransferAllTo()
.TransferAllFrom()
.Remove()
);
})
.Events(events => events
.Change("onChange"))
.ConnectWith("selected")
.Selectable(ListBoxSelectable.Multiple)
.Draggable()
.DropSources("selected")
.DataTextField("FullName")
.DataValueField("EmployeeCompanyId")
.DataSource(source => source
.Read(read => read.Action("GetEmployees","Setup",new { area = "Admin" }))
)
)
这是我的 onChange 函数:
function onChange(e) {
var item = e.sender.element;
}
解决方法
好的,我想通了。我将“onChange”功能更改为:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Merge : MonoBehaviour
{
public GameObject Circle;
public GameObject Heptagon;
public GameObject Hexagon;
public GameObject Octagon;
public GameObject Pentagon;
public GameObject Square;
public GameObject Triangle;
//NOTE: MonoBehaviour Messages like Start and Update are called even if they are empty
//NOTE: Thus only causing unnecessary overhead => If you don't need them always remove them
public void OnCollisionEnter2D(Collision2D collision)
{
var otherTransform = collision.transform;
var otherObject = collision.gameObject;
// In general rather use CompareTag instead of ==
if (otherObject.CompareTag("Triangle"))
{
Debug.Log("Merged !!!");
// Destroy the object we collide with
Destroy(otherObject);
// and our self
Destroy(gameObject);
// Then spawn the new object in the position of the hit object
Instantiate(Circle,(Vector2)otherTransform.position,Quaternion.identity);
}
else if (otherObject.CompareTag("Circle"))
{
Debug.Log("Merged !!!");
Destroy(otherObject);
Destroy(gameObject);
Instantiate(Square,Quaternion.identity);
}
else if (otherObject.CompareTag("Square"))
{
Debug.Log("Merged !!!");
Destroy(otherObject);
Destroy(gameObject);
Instantiate(Pentagon,Quaternion.identity);
}
else if (otherObject.CompareTag("Pentagon"))
{
Debug.Log("Merged !!!");
Destroy(otherObject);
Destroy(gameObject);
Instantiate(Hexagon,Quaternion.identity);
}
else if (otherObject.CompareTag("Hexagon"))
{
Debug.Log("Merged !!!");
Destroy(otherObject);
Destroy(gameObject);
Instantiate(Heptagon,Quaternion.identity);
}
else if (otherObject.CompareTag("Heptagon"))
{
Debug.Log("Merged !!!");
Destroy(otherObject);
Destroy(gameObject);
Instantiate(Octagon,Quaternion.identity);
}
}
}