vtfuture / BForms

Bootstrap Forms for ASP.NET MVC
MIT License
62 stars 33 forks source link

Grid : inlineAction event not getting added #242

Closed gunaseelanra closed 8 years ago

gunaseelanra commented 9 years ago

After adding new record to grid, inline event for delete button is not working...

meister-d commented 8 years ago

Hi BForms Team, as gunaseelanra stated in his post on June 20 i experienced the same problem after the creation of new rows. The delete Icon does not show any popup on the new rows. I have to expand the row first so that the delete button works correctly...

While checking the js implementation if found this event:

this._trigger('afterAdd', 0, { row: row, data: data });

and I added it to my Grid init:

this.$grid.bsGrid({ uniqueName: 'pmgrNamingConventionGrid', pagerUrl: this.options.pagerUrl, detailsUrl: this.options.getRowsUrl, beforeRowDetailsSuccess: $.proxy(this._beforeDetailsSuccessHandler, this), afterRowDetailsSuccess: $.proxy(this._afterDetailsSuccessHandler, this), afterAdd: $.proxy(this._afterAddHandler, this), inlineActionSelector: '.js-inlineAction', ....

Now I would like to initialise the delete Button for the newly Added Row:

//#region Add Handler

pmgrnamingconventionIndex.prototype._afterAddHandler = function (e, data)
{

    $row = data.row;

    var $btn = $row.find(this.options.btnSelector);

    $btn.bsInlineQuestion({
        question: "Are you sure?",
        placement: 'auto',
        buttons: [{
            text: 'Yes',
            cssClass: 'btn-primary bs-confirm',
            callback: $.proxy(function () {
                var data = [];
                data.push({
                    Id: $row.find('objid')
                });

                this._ajaxDelete($row, data, options.url, function () {

                    context._getPage(true);

                }, function (response) {

                    if ($(options.btnSelector).is('.js-inlineAction')) {

                        context._pagerAjaxError(response, $row);

                    } else {

                        context._rowActionAjaxError(response, $row);

                    }
                });

                $btn.bsInlineQuestion('toggle');
            }, this)
        },
            {
                text: 'No',
                cssClass: 'btn-theme bs-cancel',
                callback: function (e) {
                    $btn.bsInlineQuestion('toggle');
                }
            }]
    });
}

But this doesn't seem to work.

What would be the best approach to solve this problem? Is this event "public" or are there other reasons that it not shown in the doc?

Regards Dumitru

meister-d commented 8 years ago

Hi Cristi, thanx again for your support! For me it works now.