开发者

what's wrong with the script?

开发者 https://www.devze.com 2022-12-17 13:00 出处:网络
can figure out what\'s wrong? always returns failure function addItem() { var rowCount = $(\'#grid\').getGridParam(\'records\');

can figure out what's wrong? always returns failure

function addItem() {
            var rowCount = $('#grid').getGridParam('records');
            var lastRow = $('#grid').getRowData(rowCount - 1);

            var newRow = lastRow;
            newRow.Id = "0";
            newRow.Person = "";
            newRow.Date = "";

            var 开发者_JAVA技巧newItem = $('grid').addRowData(rowCount - 1, newRow);

            if (newItem == true) {
                alert('success');
            }
            else { alert('falire'); }
        }


I don't know, but perhaps this:

var newItem = $('grid').addRowData(rowCount - 1, newRow);

Should be this:

var newItem = $('#grid').addRowData(rowCount - 1, newRow); // missing pound sign

-- edit:

And if this turns out to be the problem, I suggest you define the names of things at the top, like so:

var theGridElement = $("#grid");

Thus helping in these little mistakes of minor inconsistency :)

0

精彩评论

暂无评论...
验证码 换一张
取 消