Я пытаюсь клонировать строку в виджете ejgrid в необходимой JS 1.X Syncfusion.
Я пробовал различные методы из старой школы JS, jQuery низкого уровня и ссылался на официальную документацию JS API безрезультатно.Надеюсь, кто-то уже использовал эту технологию раньше ...
//grid population
$('#lstSelected').ejGrid({
dataSource: [],
enableRowHover: true,
allowTextWrap: true,
allowSorting: true,
allowFiltering: false,
allowSelection: false,
allowResizing: true,
allowScrolling: true,
scrollSettings: { height: $(window).height() - 250, width: "100%" },
columns: [
{ headerText: "", template: true, templateID: "#savechktmp", width: 50, textAlign: "center", type: "string" },
{ field: "BP_ID", visible: false, isPrimaryKey: true, defaultValue: 0 },
{ field: "Package_Type", headerText: "Type", type: "string", width: 100, foreignKeyField: "value", foreignKeyValue: "text", dataSource: pkgtypes },
{ field: "Package_Description", headerText: "Description", type: "string", width: 200 },
{ field: "Customer_ID", headerText: "Customer", type: "string", width: 220, foreignKeyField: "value", foreignKeyValue: "text", dataSource: customerList },
{ field: "Subdivision_ID", headerText: "Subdivision", type: "string", width: 220, foreignKeyField: "value", foreignKeyValue: "text", dataSource: subdivisionList },
{ field: "HoursWithChildren", headerText: "Hours (*)", type: "numeric", format: "{0:N0}", width: 100 },
{ 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: "Add", buttonOptions: { width: "80%", text: "+", click: "cloneRow" } }
],
width: 130
}
],
//this is my function attempts
function cloneRow() {
//JS attempt
var tableDiv = document.getElementById('lstSelected');
var tableClass = tableDiv.getElementsByClassName('e-table')[1];
console.log(tableClass);
tableDiv.appendChild(tableClass);
resizeGrids();
}
//jQuery attempt
function cloneRow() {
var $tableBody = $('#Grid').find("tbody"),
$trLast = $tableBody.find("tr:last"),
$trNew = $trLast.clone();
$trLast.after($trNew);
var $lastRow = $("[id$=blah] tr:not('.ui-widget-header'):last");
//grab row before the last row
var $newRow = $lastRow.clone();
//clone it
$newRow.find(":text").val("");
//clear out textbox values
$lastRow.after($newRow);
//add in the new row at the end
}
}
Я бы хотел, чтобы ряд был клонирован с полной функциональностью, а не с зачищенной версией.У меня также есть демо / попытка здесь: http://jsplayground.syncfusion.com/dexgxk03