Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline edit with list type issue #1789

Open
Rimokas opened this issue Aug 14, 2018 · 1 comment
Open

Inline edit with list type issue #1789

Rimokas opened this issue Aug 14, 2018 · 1 comment
Labels
Bug This needs fixing Reproducer: Present This PR or issue contains code, which reproduce the problem described or clearly understandable MCVE

Comments

@Rimokas
Copy link

Rimokas commented Aug 14, 2018

Hi,

Editing cell in 'list' type bug.

All is working ok, then 'list' type column is visible in grid.

If this column is in right-side of grid, that must to scroll horizontal view, then editing isn't allowed . It blink at first column and after that no any column can be editable, until refresh page.

Simply extende test/grid.html sample with some columns, that list column will be not visible and try to edit :

`
$(function () {
var people = [
{ id: 1, text: 'John Cook' },
{ id: 2, text: 'Steve Jobs' },
{ id: 3, text: 'Peter Sanders' },
{ id: 4, text: 'Mark Newman' },
{ id: 5, text: 'Addy Osmani' },
{ id: 6, text: 'Paul Irish' },
{ id: 7, text: 'Doug Crocford' },
{ id: 8, text: 'Nicolas Cage' }
];

$('#grid').w2grid({
    name    : 'grid',
    header    : 'List of Names',
    show: {
        toolbar: true,
        footer: true,
        header: true,
        emptyRecords: false,
        selectColumn: true,
        expandColumn: false,
        columnHeaders: true,
        lineNumbers: true,
        toolbarDelete: true,
        toolbarSave: true,
        toolbarAdd: true
    },
    onClick: function (event) {
        var tg = $(event.originalEvent.target);
        if (tg[0].tagName == 'DIV') tg = tg.parents('td');
        if (tg.hasClass('w2ui-col-select')) {
            console.log('clicked on select row checkbox');
        }
    },
    onSelect: function () {
    },
    // selectType: 'cell',
    columns: [
        { field: 'recid', caption: 'ID', size: '80px', sortable: true, searchable: 'int', frozen: true },
        { field: 'int', caption: 'int', size: '80px', sortable: true, resizable: true,
          editable: function (record, index, col_index, data) {
              // only odd 'recid' records are editable
              if (record.recid % 2) return { type: 'int', min: 0, max: 100 };
          } },
        { field: 'money', caption: 'money', size: '80px', sortable: true, resizable: true, editable: { type: 'money' }, render: 'money' },
        { field: 'percent', caption: 'percent', size: '80px', sortable: true, resizable: true, editable: { type: 'percent' }, render: 'percent' },
        { field: 'hex', caption: 'hex', size: '80px', sortable: true, resizable: true, editable: { type: 'hex' } },
        { field: 'color', caption: 'color', size: '80px', sortable: true, resizable: true, editable: { type: 'color' } },
        { field: 'date', caption: 'date', size: '80px', sortable: true, resizable: true, editable: { type: 'date' } },
        { field: 'time', caption: 'time', size: '80px', sortable: true, resizable: true, editable: { type: 'time' } },
        { field: 'text1', caption: 'text1', size: '120px', sortable: true, resizable: true, editable: { type: 'text' } },
        { field: 'list', caption: 'list', size: '50%', sortable: true, resizable: true,
            editable: { type: 'list', align: 'left', items: people }
        },
        { field: 'combo', caption: 'combo1', size: '50%', sortable: true, resizable: true, editable: { align: 'left', type: 'combo', items: people } },
        { field: 'select', caption: 'select', size: '100px', sortable: true, resizable: true,
            editable: { type: 'select', items: people },
            render: function (record, index, col_index) {
                var html = '';
                for (var p in people) {
                    if (people[p].id == this.getCellValue(index, col_index)) html = people[p].text;
                }
                return html;
            }
        },
        { field: 'check', caption: 'check', size: '40px', sortable: true, resizable: true,
            editable: function (record, index, col_index, data) {
              // only odd 'recid' records are editable
              if (record.recid % 2) return { type: 'checkbox' }
           } },
        { field: 'text2', caption: 'text2', size: '120px', sortable: true, resizable: true, editable: { type: 'text' } },
        { field: 'text3', caption: 'text3', size: '120px', sortable: true, resizable: true, editable: { type: 'text' } },
        { field: 'text4', caption: 'text4', size: '120px', sortable: true, resizable: true, editable: { type: 'text' } },
        { field: 'list2', caption: 'list2', size: '50%', sortable: true, resizable: true,
            editable: { type: 'list', align: 'left', items: people }
        },
    ]
});
var fname = ['Vitali', 'Katsia', 'John', 'Peter', 'Sue', 'Olivia', 'Thomas', 'Sergei', 'Snehal', 'Avinash', 'Divia'];
var lname = ['Peterson', 'Rene', 'Johnson', 'Cuban', 'Twist', 'Sidorov', 'Vasiliev', 'Yadav', 'Vaishnav'];
// add 10k records
for (var i = 0; i < 15; i++) {
    w2ui['grid'].records.push({
        recid : (i + 10),
        list1 : { id: 1, text: 'some' },
        int: 4,
        float: 5,
        money: 6,
        check: Math.random() > 0.9 ? true : false,
        select: 2,
        text1: '',
        text3: '',
        text3: '',
        text4: '',
        list2 : { id: 1, text: 'some' },
    });
}
w2ui.grid.records[0].editable = false;
w2ui.grid.records[1].editable = false;
w2ui.grid.records[2].editable = false;
w2ui.grid.total = w2ui.grid.records.length;
w2ui.grid.buffered = w2ui.grid.records.length;
w2ui.grid.refresh();

});

`
I added some columns 'text' type - 'text1', 'text2' ... and the last column 'list2' as 'list' type.

Thanks in advance ...

@mpf82
Copy link
Collaborator

mpf82 commented Feb 17, 2021

I can confirm that this bug still exists in the current master.

Fiddle: http://jsfiddle.net/h21y8uzj/

@mpf82 mpf82 added Bug This needs fixing Reproducer: Present This PR or issue contains code, which reproduce the problem described or clearly understandable MCVE labels Apr 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This needs fixing Reproducer: Present This PR or issue contains code, which reproduce the problem described or clearly understandable MCVE
Projects
None yet
Development

No branches or pull requests

2 participants