BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
$("#lstSelected").ejGrid({
dataSource: window.gridData,
allowPaging: true,
toolbarSettings: { showToolbar: true, toolbarItems: ["add", "edit", "delete", "update", "cancel"] },
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true },
columns: [
{ field: "OrderID", isPrimaryKey: true, visible:false },
{ field: "EmployeeID" , editType:"dropdownedit"},
{ field: "Freight", editType: "numericedit" },
{ field: "ShipCountry" },
{
headerText: "",
commands: [
{
type: "clone",
buttonOptions: {
text: "+",
width: "100",
click: "cloneRow"
}
}
],
isUnbound: true,
}
]
});
});
function cloneRow(args) {
var gridObj = $('#lstSelected').data('ejGrid');
var data = gridObj.getSelectedRecords();
gridObj.addRecord({ OrderID: Math.random(), EmployeeID: data[0].EmployeeID, Freight: data[0].Freight, ShipCountry: data[0].ShipCountry });
}
</script>
|
<script type="text/X-jsrender" id="savechktmp">
<input type="checkbox" />
</script>
<script type="text/x-jsrender" id="floortmp">
<input id="Floor{{:BP_ID}}" class="floor" />
</script>
<script type="text/x-jsrender" id="locationtmp">
<input id="Location{{:BP_ID}}" class="location" />
</script>
<script type="text/x-jsrender" id="qtytmp">
<input id="Qty{{:BP_ID}}" class="qty" />
</script>
<div id="bwpopup"></div>
<div id="lstSelected"></div>
<script>
$("#bwpopup").ejButton({
click: "additem",
text: "insert",
})
function additem(args) {
var selectedItems = [{
BP_ID: 12, Package_Type: "B", Package_Description: "Heelo", HoursWithChildren: "0 hour", Floor: "1st Floor", Location: "Bar 1", Qty: 1
}]
var obj = $("#lstSelected").ejGrid("instance");
$('#lstSelected').ejGrid('model.dataSource', selectedItems); // updated grid data using dataSource method.
}
var pkgtypes = [{ value: "B", text: "Base" }, { value: "U", text: "Upgrade" }]
var items1 = [ …];
var items2 = [……..];
$('#lstSelected').ejGrid({
……………
templateRefresh: "refresh",
editSettings: { allowEditing: false, allowAdding: true, allowDeleting: false },
columns: [
{ headerText: "", template: true, templateID: "#savechktmp", width: 50, textAlign: "center", type: "string" },
{ field: "BP_ID", visible: false, isPrimaryKey: true, defaultValue: 0 },
…………..
{ field: "Floor", headerText: "Location", width: 150, template: true, templateID: "#floortmp" },
{ field: "Location", headerText: "Room", width: 150, template: true, templateID: "#locationtmp" },
{ field: "Qty", headerText: "Qty", width: 100, template: true, templateID: "#qtytmp" },
{
headerText: "", textAlign: "center",
commands: [
{ type: "clone", buttonOptions: { width: "80%", text: "+", click: "cloneRow" } }
],
width: 130
}
],
});
function cloneRow(args) {
var gridObj = $('#lstSelected').data('ejGrid');
var index = $(args.target).index();
var data = gridObj.model.currentViewData[index]; // use model.currentViewData to get the data.
gridObj.addRecord({
BP_ID: Math.ceil(Math.random() * 100), Package_Type: data.Package_Type, Package_Description: data.Package_Description, HoursWithChildren: data.HoursWithChildren, Floor: data.Floor, Location: data.Location, Qty: data.Qty
});
var row = $(args.target).closest("tr");
row.prev().before(row); // find the newly added row and change its position.
}
function refresh(args) {
if ($(args.cell).find(".floor").length) {
$(args.cell).find(".floor").ejDropDownList({
dataSource: items1, // define the dataSource here
selectedItemIndex: 0,
fields: {
text: "text",
value: "value"
}
});
}
else if ($(args.cell).find(".location").length) {
$(args.cell).find(".location").ejDropDownList({
dataSource: items2,
selectedItemIndex: 0,
fields: {
text: "text",
value: "value"
}
});
}
else if ($(args.cell).find(".qty").length) {
$(args.cell).find(".qty").ejNumericTextbox({ value: 1 });
}
}
</script>
|