jQWidgets Forums

jQuery UI Widgets Forums Grid initEverPresentRow/resetEverpresentRow

This topic contains 1 reply, has 1 voice, and was last updated by  Manowar 8 years, 9 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • initEverPresentRow/resetEverpresentRow #87139

    Manowar
    Participant
    $("#detail").jqxGrid(
                        {
                            width: 920,
                            source: dataAdapter,
                            autoheight: true,
                            editable: true,
                            sortable: true,
                            showeverpresentrow: false,
                            everpresentrowactionsmode: 'columns',
                            localization: {
                                addrowstring: 'Добавить',
                                resetrowstring: "Очистить",
                                everpresentrowplaceholder: " "
                            },
                            everpresentrowposition: "bottom",
                            editmode: 'dblclick',
                            selectionmode: 'singlerow',
                            columns: [
                                {
                                    text: "№ п/п", datafield: "DetailNumber", width: 130,
                                    initEverPresentRowWidget: function (datafield, htmlElement) {
                                        var rowscount = $("#detail").jqxGrid('getdatainformation').rowscount;
                                        htmlElement = htmlElement[0].firstChild;
                                        
                                        if (initCount == undefined) {
                                            $(htmlElement).val(rowscount + 1);
                                            initCount = 1;
                                            alert(1);
                                        } else {
                                            initCount = undefined;
                                            alert(2);
                                            $(htmlElement).val(rowscount + 2);
                                        }
    
                                    },
                                    resetEverPresentRowWidgetValue: function (datafield, htmlElement) {
                                        alert("reset");
                                    }
                                },
                                {
                                    text: "Количество", datafield: "Amount", width: 90
                                },
                                {
                                    text: "Дата", datafield: "Date", columntype: 'datetimeinput', width: 100, cellsformat: 'dd.MM.yy',
                                    createEverPresentRowWidget: function (datafield, htmlElement, popup, addCallback) {
                                        var inputTag = $("<div style='border: none;'></div>").appendTo(htmlElement);
                                        inputTag.jqxDateTimeInput({ value: null, popupZIndex: 99999999, placeHolder: "Дата: ", width: '100%', height: 30, culture: "ru-RU", formatString: 'dd.MM.yy' });
                                        $(document).on('keydown.date', function (event) {
                                            if (event.keyCode == 13) {
                                                if (event.target === inputTag[0]) {
                                                    addCallback();
                                                }
                                                else if ($(event.target).ischildof(inputTag)) {
                                                    addCallback();
                                                }
                                            }
                                        });
    
                                        return inputTag;
                                    },
                                    initEverPresentRowWidget: function (datafield, htmlElement) {
                                        htmlElement = htmlElement[0].firstChild;
                                    },
                                    getEverPresentRowWidgetValue: function (datafield, htmlElement, validate) {
                                        var value = htmlElement.val();
                                        return value;
                                    },
                                    resetEverPresentRowWidgetValue: function (datafield, htmlElement) {
                                        htmlElement.val(null);
                                    }
                                },
                                {
                                    text: "Название", datafield: "FoodName", width: 200,
                                    initEverPresentRowWidget: function (datafield, htmlElement) {
                                        autoFilledEverPresentCell = htmlElement[0].firstChild;
                                    },
                                },
                                {
                                    text: "Название из fooFood", datafield: "FoodID", displayfield: "fooFoodName", columntype: "dropdownlist", width: 200,
                                    createeditor: function (row, value, editor) {
                                        editor.jqxDropDownList({ source: foodAdapter, valueMember: 'FoodID', displayMember: 'Name'/*, autoBind: true*/ });
                                    },
                                    createEverPresentRowWidget: function (datafield, htmlElement, popup, addCallback) {
                                        var inputTag = $("<div style='border: none;'></div>").appendTo(htmlElement);
                                        inputTag.jqxDropDownList({ source: foodAdapter, valueMember: 'FoodID', displayMember: 'Name', placeHolder: "Продукт: "/*, autoBind: true*/ });
    
                                        $(inputTag).on('select', function (event) {
                                            var args = event.args;
                                            var item = $(inputTag).jqxDropDownList('getItem', args.index);
                                            $(autoFilledEverPresentCell).val(item.label);
                                        });
    
                                        $(document).on('keydown.fooFoodName', function (event) {
                                            if (event.keyCode == 13) {
                                                if (event.target === inputTag[0]) {
                                                    addCallback();
                                                }
                                                else if ($(event.target).ischildof(inputTag)) {
                                                    addCallback();
                                                }
                                            }
                                        });
                                        return inputTag;
                                    },
                                    initEverPresentRowWidget: function (datafield, htmlElement) { },
                                    getEverPresentRowWidgetValue: function (datafield, htmlElement, validate) {
                                        var selectedItem = htmlElement.jqxDropDownList('getSelectedItem');
                                        if (!selectedItem)
                                            return "";
                                        var value = selectedItem.value
                                        return value;
                                    },
                                    resetEverPresentRowWidgetValue: function (datafield, htmlElement) {
                                        htmlElement.jqxDropDownList('clearSelection');
                                    },
                                },
                                { text: '', datafield: 'addButtonColumn', width: 100 },
                                { text: '', datafield: 'resetButtonColumn', width: 100 }
                            ]
                        });

    Hi, guys
    in this field:
    text: “№ п/п”, datafield: “DetailNumber”, width: 130
    I want to do the following – when everpresentrow init for the first time to autofill that field with a number according to order
    after that, when new row is added, to autofill that field for the second time, but for that number to be more then previous by one
    how can I achieve that? Cause I just cant understand the mechanics of how those events work – init is called two times, when I open everpresentrow for the first time and when I add new row with it

    initEverPresentRow/resetEverpresentRow #87197

    Manowar
    Participant

    problem solved

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.