Hi
I have a dropdownlist that is setup like this:
<
div
class
=
"requisitionForm-content"
>
@(Html.Kendo().DropDownListFor(m => m.RequisitionModel.FormDto.VendorIdentifier)
.Events(e => e.Change("onVendorChange"))
.OptionLabel("Select a vendor...")
.DataValueField("Identifier")
.DataTextField("Name")
.Filter(FilterType.Contains)
.DataSource(s => s.Read(r => r.Action("GetVendors", "RequisitionForm", new { formVendor = Model.RequisitionModel.FormDto.VendorIdentifier }).Type(HttpVerbs.Post).Data("getVendorExtraData")))
.HtmlAttributes(new { style = "width:360px" }))
</
div
>
When a selection is made, it populates some text fields on the page. onVendorChange is pretty simple:
function
onVendorChange(e) {
var
phone =
""
;
var
address =
""
;
var
fax =
""
;
var
email =
""
;
var
vendorDropList = $(
'#RequisitionModel_FormDto_VendorIdentifier'
).data(
"kendoDropDownList"
);
var
dataItem = vendorDropList.dataItem();
if
(dataItem) {
phone = dataItem.Phone ? dataItem.Phone :
""
;
address = dataItem.Address ? dataItem.Address :
""
;
fax = dataItem.Fax ? dataItem.Fax :
""
;
email = dataItem.Email ? dataItem.Email :
""
;
var
requisitionList = $(
'#RequisitionModel_FormDto_RequisitionType'
).data(
"kendoDropDownList"
);
var
reqType = requisitionList.dataItem();
if
(dataItem.BlanketOrderPo &&
reqType &&
reqType.Identifier ==
"@RequisitionType.BlanketOrder.Identifier.ToString()"
) {
$(
'#RequisitionModel_FormDto_PoNumber'
).val(dataItem.BlanketOrderPo);
}
}
$(
'#RequisitionModel_FormDto_VendorContactPhone'
).val(phone);
$(
'#RequisitionModel_FormDto_VendorAddress'
).val(address);
$(
'#RequisitionModel_FormDto_VendorFax'
).val(fax);
$(
'#RequisitionModel_FormDto_VendorEmail'
).val(email);
}
I am trying to save the state of form in localstorage. I am retaining the "Identifier" value.
I am restoring the state of the form by:
(elem is the specific dropdownlist element)
.. snip ..
$(elem).data(
'kendoDropDownList'
).value(formObject[key]);
$(elem).data(
'kendoDropDownList'
).trigger(
"change"
);
.. snip ..
The dropdownlist shows the correct name, but it acts as though the onChange event does not trigger: none of the related text fields are populated.
However, if I run the following at the browser's console:
$(
"#RequisitionModel_FormDto_VendorIdentifier"
).data(
"kendoDropDownList"
).trigger(
"change"
);
the change event is triggered.
It feels like it's a bit of a race condition - the dropdownlist hasn't populated it's data yet, or .. something?
How can I wait for the dropdownlist to be ready to be triggered? Is there a better way to handle this?
Thanks in advance.
Hi,
I'm looking for a way to show the sum of a column on the group line like in this example : https://docs.telerik.com/kendo-ui/knowledge-base/grid-align-group-header-with-cells, but for every group possible. In others words, I would like to show, let's say the total of Completed tasks no matter the grouping so if I group by age, the total of Completed tasks will be shown on the group header. If I group by age, the total of Completed tasks would be shown on the group header as well.
By enabling the grouping in the Grid, it seems that this only works for the group specified in the data source.
Please see my example : https://dojo.telerik.com/OcuquWOd
As you can see, the Count is only shown when the grid is grouped by Units in stocks. When the group is on another column, the Count is no more shown.
Do you have any idea on how to achieve this ?
Thanks,
Hi,
I'm trying to create an event on double click on a selected cell in the scheduler.
I have already implemented right click and drag event create and left click and create event
The below code is for create event on right click and drag
view.element.on("mouseup", ".k-scheduler-content td", function(e) {
if(e.which===1){
let scheduler = this;
let selection = scheduler.select();
let slot = scheduler.slotByElement($(e.target));
let resource = scheduler.resourcesBySlot(slot);
let roomId = resource.RoomID;
if (selection.events && !selection.events.length ) {
if(selection.slots.length>1){
//no events are selected then this is create
scheduler.select(null);
scheduler.addEvent({
reservationId:newResNumber,
title:"No Title",
FirstName:"Jane",
LastName:"Doe",
start: selection.start,
end: selection.end,
RenderColor:"#FFFFCE",
RoomID: roomId,
CheckedIn:true,
Moveable:true
});
}
}
}
});
How can i create event on double click on a selected event
Is there a way to disable auto-fill on the spreadsheet? We don't want our clients to accidentally activate it and over-write data they've already entered in the spreadsheet.
Thanks.
Greg
I am evaluating Kendo UI for Jquery.
I need the spreadsheet grid control to input a very specific excel file. In the end, I need to turn it into a web form.
That form data would write to a MySQL database. Another web page would read from the database and populate the spreadsheet with data.
Can this be done with the spreadsheet control?
If not, can it be done with the data grid or other Kendo UI controls?
If so, please explain how I would accomplish this.
Thank you.
Mike
I have two kendo ui grid in one html page. They displayed based on the options that user choose in dropdownlist. For example, if I chose 1, the first grid displayed and the second one hidden. And if I choose 2, the second one displayed but first one hidden.
But after I choose 1 and add some items to grid 1, then choose 2 to switch to grid 2 and add some items to grid 2. Now when I switch back to grid 1, it display a loading icon always. I could not operate my grid 1 any more.
The attached screenshot is the issue. And following is my code. Can someone help us check what's wrong with my code? Thanks.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" href="../styles/kendo.common.min.css" />
<link rel="stylesheet" href="../styles/kendo.default.min.css" />
<link rel="stylesheet" href="../styles/kendo.default.mobile.min.css" />
<script src="../js/jquery.min.js"></script>
<script src="../js/kendo.all.min.js"></script>
<script type="text/javascript">
function SelectRawMaterType() {
var type = document.getElementById("Type");
var meat = document.getElementById("Meat");
var additive = document.getElementById("Additive");
var gridMeat = document.getElementById("gridMeat");
var gridAdditive = document.getElementById("gridAdditive");
if (type.value == 0) {
additive.style.display = "none";
meat.style.display = "block";
gridMeat.style.display = "block";
gridAdditive.style.display = "none";
}
if (type.value == 1) {
additive.style.display = "block";
meat.style.display = "none";
gridMeat.style.display = "none";
gridAdditive.style.display = "block";
}
Records();
}
function Records() {
var para = document.getElementById("Type");
if (para.value == 0) {
$(document).ready(function () {
var mydata = new kendo.data.DataSource({
transport: {
//读取数据
read: function (e) {
////alert(111);
//e.success(datasource);
},
//更新数据
update: function (e) {
e.success();
}
},
schema: {
model: {
id: "Id",
fields: {
RawName: { type: "string" },
Unit: { type: "string" },
Remark: { type: "string" }
}
}
},
pageSize: 5
});
$("#gridMeat").kendoGrid({
dataSource: mydata,
selectable: "multiple, row", //设置多列可选
filterable: true, //设置过滤可用
sortable: true, //设置排序可用
pageable: true, //设置分页可用
editable: "popup", //设置编辑模式。popup:弹窗;linline:行内编辑
columns: [{
field: "RawName",
title: "原材料名称",
width: 240
}, {
field: "Unit",
title: "原材料单位"
}, {
field: "Remark",
title: "备注"
},
{ command: ["edit"], title: "操作" }]
});
});
}
if (para.value == 1) {
$(document).ready(function () {
var mydata = new kendo.data.DataSource({
transport: {
//读取数据
read: function (e) {
////alert(111);
//e.success(datasource);
},
//更新数据
update: function (e) {
e.success();
}
},
schema: {
model: {
id: "Id",
fields: {
RawName: { type: "string" },
Unit: { type: "string" },
MaximumUsage:{ type:"string"},
Remark: { type: "string" }
}
}
},
pageSize: 5
});
$("#gridAdditive").kendoGrid({
dataSource: mydata,
selectable: "multiple, row", //设置多列可选
filterable: true, //设置过滤可用
sortable: true, //设置排序可用
pageable: true, //设置分页可用
editable: "popup", //设置编辑模式。popup:弹窗;linline:行内编辑
columns: [{
field: "RawName",
title: "原材料名称",
width: 240
}, {
field: "Unit",
title: "原材料单位"
},
{
field: "MaximumUsage",
title:"最大使用量"
}, {
field: "Remark",
title: "备注"
},
{ command: ["edit"], title: "操作" }]
});
});
}
};
$(window).load(function () {
SelectRawMaterType();
//Records();
});
function GetSourceForMeat() {
var gridMeat = $("#gridMeat").data("kendoGrid");
var datasourceOfMeat = gridMeat.dataSource;
datasourceOfMeat.insert({
RawName: "牛肉1",
Unit: "袋",
Remark: "备注1"
});
};
function GetSourceForAdditive() {
var gridAdditive = $("#gridAdditive").data("kendoGrid");
var datasourceOfAdditive = gridAdditive.dataSource;
datasourceOfAdditive.insert({
RawName: "添加剂1",
Unit: "袋",
MaximumUsage: "100ml",
Remark:"备注2"
});
};
</script>
</head>
<body>
<div class="title">
<h4>原材料管理</h4>
</div>
<div class="rawMaterType">
原材料类型:
<select id="Type" onchange="SelectRawMaterType()">
<option value="0">肉类</option>
<option value="1">添加剂</option>
</select>
</div>
<div class="itemsForMeat" id="Meat">
<div class="items">
<table>
<tr>
<td>原材料名称:</td>
<td><input type="text" name="MeatName" /></td>
<td>原材料单位:</td>
<td><input type="text" name="MeatUnit" /></td>
</tr>
<tr>
<td>备注:</td>
<td><input type="text" name="MeatRemark" /></td>
<td><input type="button" name="MeatAdd" value="添加" onclick="GetSourceForMeat()" /></td>
<td><input type="button" name="MeatDelete" value="删除选中" /></td>
</tr>
</table>
</div>
</div>
<div class="itemsForAdditive" id="Additive">
<div class="items">
<table>
<tr>
<td>原材料名称:</td>
<td><input type="text" name="AdditiveName" /></td>
<td>原材料单位:</td>
<td><input type="text" name="AdditiveUnit" /></td>
<td><input type="button" name="AdditiveAdd" value="添加" onclick="GetSourceForAdditive()" /></td>
</tr>
<tr>
<td>最大使用量:</td>
<td><input type="text" name="MaxUsage" /></td>
<td>备注:</td>
<td><input type="text" name="AdditiveRemark" /></td>
<td><input type="button" name="AdditiveDelete" value="删除选中" /></td>
</tr>
</table>
</div>
</div>
<div id="gridMeat" class="records">
</div>
<div id="gridAdditive" class="records">
</div>
</body>
</html>
I have this code:
http://dojo.telerik.com/OPaGEXik
It works fine until addHistory() function is not fired. After that, the last added row in the gird is throwing "Object expected" when expanded.
In the dojo and the button added the error is a bit different but I think the root of the problem is the same.
What is the issue here?