gpt4 book ai didi

javascript - 获取/获取在 Kendo DropdownList 的数据源上查询的数据并在 Google map 上使用它

转载 作者:行者123 更新时间:2023-11-30 17:34:05 26 4
gpt4 key购买 nike

我能问一下在被查询的数据源中获取值的方法是什么并使用它吗,因为在我的 Json 结果中有纬度和经度列,我想用它来使 map 中心 onchange位置下拉

这是我的位置下拉列表

        $("#ddlLocation").kendoDropDownList({
dataTextField: "Address",
dataValueField: "Client_CustomerID",
autoBind: false,
optionLabel: "-- Please Select Position --",
template: '<h5>${ data.Address }</h5>',
dataSource: {
transport: {
read: {
url: '/Dashboard/LoadCompanyDropdownList?userId=' + userId,
dataType: "json",
type: "POST"
}
}
}
});

$("#LocationInputs").kendoDropDownList({
dataTextField: "Address",
dataValueField: "Client_CustomerID",
// index: 0,
autoBind: false,
change: function () {
var value = this.value();
if (value) {


**This is where i want to use the fetched Latitude and Longitude**


}
else {
$("#PositionGrid").data("kendoGrid").dataSource.filter({});
}
},
cascadeFrom: "PositionInputs",
optionLabel: "-- Please Select Position --",
template: '<h5>${ data.Address }</h5>',
dataSource: {
transport: {
read: {
url: '/Dashboard/LoadCompanyDropdownList?userId=' + userId,
dataType: "json",
type: "POST"
}
}
}
});

这是 LoadCompanyDropdownList

 public JsonResult LoadCustomerList()
{


// check if search string has value
// retrieve list of workers filtered by search criteria
var list = (from a in db.Client_Customer_Location
join b in db.Client_Customer
on a.Client_CustomerID equals b.ID
where a.LogicalDelete == false
&& b.LogicalDelete == false
&& a.Longitude != null
&& a.Longitude != 0

select new
{
b.ID,
a.Client_CustomerID,
a.Address_Line1,
a.Address_Line2,
a.City,
a.STATE_LookID,
a.ZipCode,
a.Latitude,
a.Longitude,
a.LogicalDelete,
}).ToList();

List<CustomerInfo> clist = new List<CustomerInfo>();
foreach (var row in list)
{
CustomerInfo ci = new CustomerInfo
{
ID = row.ID,
Client_CustomerID = row.Client_CustomerID,
ClientID = row.ClientID,
AddressLine1 = row.Address_Line1 + " " + row.Address_Line2 + " " + row.City + " " + GetLookupDisplayValById(row.STATE_LookID),

Latitude = Math.Round(Convert.ToDecimal(row.Latitude), 8),
Longitude = Math.Round(Convert.ToDecimal(row.Longitude), 8),
LogicalDelete = row.LogicalDelete

};
clist.Add(ci);
}

return Json(clist.ToList().OrderBy(p => p.AddressLine1), JsonRequestBehavior.AllowGet);
}

最佳答案

你可以试试这个:

change: function () {
var dataItem = this.dataItem(this.select());
var lat = dataItem.Latitude;
var long = dataItem.Longitude;

var value = this.value();
if (value) {
........
}

关于javascript - 获取/获取在 Kendo DropdownList 的数据源上查询的数据并在 Google map 上使用它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22395106/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com