How to manage Enter keycode in inline mode

How to manage Enter keycode in inline mode

5320835@qq.com5320835@qq.com Posts: 15Questions: 5Answers: 0
edited December 2016 in Free community support

Hi Allen,

I would like to know how can I manage the enter keycode under Editor inline mode, the goal is I want to submit multi rows by customized button instead of submit one by one.

Here is my code

For Editor

            pceditor = new $.fn.dataTable.Editor({
                idSrc: 'ProductCode',
                table: '#PriceChangeTable',
                fields: [
                    { label: '序号: ', name: 'Sequence_number' },
                    { label: '序号: ', name: 'ProductCode' },
                    { label: '描述: ', name: 'ProductName' },
                    { label: '类型: ', name: 'Color' },
                    { label: '状态: ', name: 'Size' },
                    { label: '状态: ', name: 'NewPrice' },
                    { label: '状态: ', name: 'RetailPrice' },
                    { label: '状态: ', name: 'LandedCost' },
                ],
                ajax: function (method, url, data, success, error) {
                    // NOTE - THIS WILL WORK FOR EDIT ONLY AS IS
                    if (data.action === 'edit') {
                        success({
                            data: $.map(data.data, function (val, key) {
                                val.DT_RowId = key;
                                console.log(val)
                                return val;
                            })
                        });
                    }
                }
            });

For Inline

            $('#PriceChangeTable').on('click', 'tbody td.editable', function (e) {
                pceditor.inline(this, {
                    onBlur: 'submit',
                    //onComplete:'none',
                    submit: 'all',
                    onReturn: 'none',
                    onBackground: close
                });
            });

I copied some codes from another discussion which works fine except handle Enter after key-in value (here is NewPrice).

Thanks.

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Replies

  • allanallan Posts: 61,705Questions: 1Answers: 10,102 Site admin

    Editor's inline mode doesn't really allow this I'm afraid. Certainly the built in Ajax option will always submit after every inline edit.

    With the new 1.6 version it is actually possible, although you need to make the Ajax call yourself. 1.6 has a new local table editing option, so you can have just the table update. Then when you are ready to submit the data use row().data() to get the data and submit it to the server.

    Allan

This discussion has been closed.