Как клонировать строку при нажатии кнопки в необходимом виджете js 1.X ejgrid - PullRequest
0 голосов
/ 22 января 2019

Я пытаюсь клонировать строку в виджете 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

1 Ответ

0 голосов
/ 23 января 2019

Запрос: Я бы хотел, чтобы строка была клонирована, с полной функциональностью строки, а не с удаленной версией .

Из общей демонстрации мы увидим, что вы добавили клонированную строку под текущей строкой. Поскольку клонированная строка не обновляется в источнике данных , мы не можем выполнить сеточные функции, такие как s ортопедия, редактирование, фильтрация и т. Д. ., Для клонированной строки .

А также нам нужны дополнительные детали относительно вашего требования. Поэтому, пожалуйста, вернитесь к нам со следующей информацией.

  1. Пожалуйста, подтвердите, хотите ли вы выполнить сеточные действия для клонированной строки (то есть сортировка, фильтрация и т. Д.)
  2. Если нет, объясните подробно ваше требование.
  3. А также мы хотели бы знать причину клонирования строки сетки.

Запрашиваемая информация поможет нам удовлетворить ваши требования как можно раньше.

...