Base solution for your next web application
Open Closed

Redirect to action from jtable issue #3939


User avatar
0
Garysund created

Hi There

I Extended the Jtable user list to include a new action ICompany Profile.

{
                            text: app.localize('CompanyProfile'),
                            visible: function (data) {
                                return data.record.id !== abp.session.userId;
                            },
                            action: function (data) {
                                abp.ajax({
                                    url: abp.appPath + 'Mpa/CompanyAdmin/Index',
                                    data: JSON.stringify({
                                        userId: data.record.id
                                    })
                                });
                            }
                        },

When I click on the action it steps into the controller and passes through the data correctly but when it tries to return the view it does nothing then gives an error. It does not log anything in the logs.

Controller

public async Task<ActionResult> Index(CompanyAdminModel input)
        {
            var businessUnits = await _documentFilterAppService.GetBusinessUnitsForCombobox();
            var userid = input.UserId;
            var UserCustomerNumbers =  _customerNumberAppService.GetCustomerNumbersByUser(userid);
            var userProfile = await _profileAppService.GetCompanyProfileForAdminEdit(userid);
            var model = new IndexViewModel(businessUnits, UserCustomerNumbers, userProfile);
            return View(model);
        }

How to I go to a new view from a jTable action? Technically it would be leaving the user list page and going to the company profile page.

Thanks


2 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team

    Sounds like you want to do this instead:

    action: function (data) {
        window.location.href = abp.appPath + 'Mpa/CompanyAdmin/Index?userId=' + data.record.id;
    }
    
  • User Avatar
    0
    Garysund created

    Thanks solved it so simple