Base solution for your next web application
Open Closed

V4.1 Upgrade - JTable action button not rendering #3487


User avatar
0
exlnt created

I am following the solutions provided on this thread: <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero/issues/96">https://github.com/aspnetzero/aspnet-zero/issues/96</a> to upgrade my existing ASPNETZERO project to V4.1. I am using the .NET 4.6.1 MVC template.

  1. I downloaded a fresh copy of my solution and placed that into new "ABPMaster" branch.
  2. Then I took my working copy of my dev branch into new "staging" branch.
  3. Then I copy/paste all the projects and files from "ABPMaster" into "staging" branch, with replace YES option.
  4. I manually enable/copy all the custom changes I have implemented. Get a clean build of all projects.
  5. I then scaffold one EF migration for ALL ABP changes.
  6. I then scaffold one EF migration for ALL Custom changes for my app.
  7. I then applied both migrations to new DB instances.
  8. I run the app and login to host using default admin account. All of the pages in the host solution where JTable is used, do not render the "Actions" cell. Google console shows no errors and the HTML for that cell is completely empty. I cannot check or grant any permissions to admin account, as the buttons wont render! Screenshot: <a class="postlink" href="https://drive.google.com/file/d/0B5HAoiVVXzY7QlEyRkN4dHQzQnM/view?usp=sharing">https://drive.google.com/file/d/0B5HAoi ... sp=sharing</a>

33 Answer(s)
  • User Avatar
    0
    exlnt created

    One other issue/question.

    In my downloaded template I do not see the "Tenant Subscription System & Payment Integration" and dashboard updates. Are these things NOT built into the MVC template?

  • User Avatar
    0
    alper created
    Support Team

    The rendering is done in this javascript file jquery.jtable.record-actions.js So it must be included in your layout. Can you check it?

    <cite>exlnt: </cite> I am following the solutions provided on this thread: <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero/issues/96">https://github.com/aspnetzero/aspnet-zero/issues/96</a> to upgrade my existing ASPNETZERO project to V4.1. I am using the .NET 4.6.1 MVC template.

    1. I downloaded a fresh copy of my solution and placed that into new "ABPMaster" branch.
    2. Then I took my working copy of my dev branch into new "staging" branch.
    3. Then I copy/paste all the projects and files from "ABPMaster" into "staging" branch, with replace YES option.
    4. I manually enable/copy all the custom changes I have implemented. Get a clean build of all projects.
    5. I then scaffold one EF migration for ALL ABP changes.
    6. I then scaffold one EF migration for ALL Custom changes for my app.
    7. I then applied both migrations to new DB instances.
    8. I run the app and login to host using default admin account. All of the pages in the host solution where JTable is used, do not render the "Actions" cell. Google console shows no errors and the HTML for that cell is completely empty. I cannot check or grant any permissions to admin account, as the buttons wont render! Screenshot: <a class="postlink" href="https://drive.google.com/file/d/0B5HAoiVVXzY7QlEyRkN4dHQzQnM/view?usp=sharing">https://drive.google.com/file/d/0B5HAoi ... sp=sharing</a>
  • User Avatar
    0
    alper created
    Support Team

    The new dashboard update is not included in .NET 4.6.1 MVC template.

    <cite>exlnt: </cite> One other issue/question.

    In my downloaded template I do not see the "Tenant Subscription System & Payment Integration" and dashboard updates. Are these things NOT built into the MVC template?

  • User Avatar
    0
    exlnt created

    <cite>alper: </cite> The rendering is done in this javascript file jquery.jtable.record-actions.js So it must be included in your layout. Can you check it?

    Thank you very much! That script was missing from the BundleConfig.cs file! Its working now!

  • User Avatar
    0
    exlnt created

    One more question/issue.

    Is there some breaking change for how the Index view app services work in v4.1? All but one of my existing app services for index views is breaking. It seems to happen, mainly, on the index views where I have filters. It keeps failing with validation error messages? <a class="postlink" href="https://drive.google.com/file/d/0B5HAoiVVXzY7Zml1aDBjTWhMcmM/view?usp=sharing">https://drive.google.com/file/d/0B5HAoi ... sp=sharing</a>

    The log file shows this detail for the same error:

    WARN  2017-07-04 11:59:36,331 [129  ] nHandling.AbpApiExceptionFilterAttribute - Method arguments are not valid! See ValidationErrors for details.
    Abp.Runtime.Validation.AbpValidationException: Method arguments are not valid! See ValidationErrors for details.
       at Abp.Runtime.Validation.Interception.MethodInvocationValidator.ThrowValidationError()
       at Abp.Runtime.Validation.Interception.MethodInvocationValidator.Validate()
       at Abp.WebApi.Validation.AbpApiValidationFilter.<ExecuteActionFilterAsync>d__5.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Abp.WebApi.Auditing.AbpApiAuditFilter.<ExecuteActionFilterAsync>d__4.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Abp.WebApi.Security.AntiForgery.AbpAntiForgeryApiFilter.<ExecuteAuthorizationFilterAsync>d__10.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Abp.WebApi.Authorization.AbpApiAuthorizeFilter.<ExecuteAuthorizationFilterAsync>d__7.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Web.Http.Controllers.AuthenticationFilterResult.<ExecuteAsync>d__0.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()
    WARN  2017-07-04 11:59:36,331 [129  ] nHandling.AbpApiExceptionFilterAttribute - There are 1 validation errors:
    WARN  2017-07-04 11:59:36,331 [129  ] nHandling.AbpApiExceptionFilterAttribute -  (input.CompanyId)
    

    The value for input.CompanyId on all my index views is NULL, this works just fine with my existing app on ABP version 1.5. Is there something that I need to do differently?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Can you share your server side DTO class ?

    Thanks.

  • User Avatar
    0
    exlnt created

    Here is the DTO for the Index view, for the department entity. This is the same one I shared in the error screenshot above.

    [AutoMapFrom(typeof(Department))]
        public class DepartmentListDto : EntityDto, IHasCreationTime
        {
            public string CompanyName { get; set; }
    
            public int CompanyId { get; set; }
    
            public string DeptCode { get; set; }
    
            public string DepartmentName { get; set; }
    
            public string Location { get; set; }
    
            public bool ActiveYesNo { get; set; }
    
            public DateTime CreationTime { get; set; }
    
            public string CreatedByUser { get; set; }
    
        }
    
  • User Avatar
    0
    alper created
    Support Team

    i think you shared the wrong dto. What i want to see is the input dto that lists the departments. I think CompanyId has validation attribute like RangeValidator.

  • User Avatar
    0
    exlnt created

    <cite>alper: </cite> i think you shared the wrong dto. What i want to see is the input dto that lists the departments. I think CompanyId has validation attribute like RangeValidator.

    The one I shared above is correct. DepartmentListDto, is what I use on the index view page. I dont have a companyId range validator anywhere. Company is displayed as dropdown on all pages.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @exlnt,

    Can you share your project with us via <a href="mailto:[email protected]">[email protected]</a> ? In that way, we will solve your problem faster.

    Thanks.

  • User Avatar
    0
    exlnt created

    <cite>ismcagdas: </cite> Hi @exlnt,

    Can you share your project with us via <a href="mailto:[email protected]">[email protected]</a> ? In that way, we will solve your problem faster.

    Thanks.

    I actually am trying to convert my solution into the .NET Core MVC/JQuery (V4.1) template. I am facing some issue with that template too. If I am unable to get the .NET Core solution working, I will share my existing solution for this issue. Thanks!

  • User Avatar
    0
    exlnt created

    <cite>ismcagdas: </cite> Hi @exlnt,

    Can you share your project with us via <a href="mailto:[email protected]">[email protected]</a> ? In that way, we will solve your problem faster.

    Thanks.

    I have emailed you a link to my solution for the issue on this thread. Can you please take a look and let me know? Thanks!

  • User Avatar
    0
    exlnt created

    @ismcagdas - I emailed you my solution last week, I still have not gotten any reply. Can you please provide an update?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @exlnt,

    I'm really sorry for the delay. I have checked your solution and found the below problem.

    You have a int CompanyId field in GetDepartmentInput but you are sending empty string from client to server as CompanyId. According to your code in DepartmentAppService, it is better to set value of "All Companies" item to 0 like this in DepartmentController.

    public ActionResult Index()
    {
        var companies = _companyAppService.GetCompaniesComboboxItems(0);
        companies[0].DisplayText = "All Companies";
        companies[0].Value = "0";
        var model = new DepartmentListViewModel
        {
            Companies = companies
        };
        return View(model);
    }
    

    If CompanyId filter is optional, you can define CompanyId as nullable as a second option.

    Thanks.

  • User Avatar
    0
    exlnt created

    @ismcagdas - Thanks very much! Better late than never! :D

  • User Avatar
    0
    exlnt created

    One further question/help needed. I am still getting this validation error on some of my modal actions. Is there a way where I can debug the built-in ABP automatic validation that happens? When I debug in VS2017, as you have stated before, due to validation it will not reach the app service method. The log file does not show anything. When I look at Chrome console and look at the parameters passed to my app service, all the values are passed correctly. Yet I keep getting a validation error. How can I track down what exactly is causing this validation error, where is source code for the built-in ABP validation that happens?

  • User Avatar
    0
    exlnt created

    Here is one specific example.

    Here you can see the validation errors that are reported on the chrome console: <a class="postlink" href="https://drive.google.com/open?id=0B5HAoiVVXzY7a1VWNUR1NDhENU0">https://drive.google.com/open?id=0B5HAo ... UR1NDhENU0</a>

    Here is the DTO used on that app service, as you can see the properties reported in the validation are NOT required. <a class="postlink" href="https://drive.google.com/open?id=0B5HAoiVVXzY7VWttdXhiUER1V3c">https://drive.google.com/open?id=0B5HAo ... XhiUER1V3c</a>

    Why is it throwing validation error here?

  • User Avatar
    0
    exlnt created

    I am now running into the same validation error on my other project where I am using the basic open source ABP template. Again my app service is getting all the required values passed into method but the ABP validation keeps throwing validation error message.

    I did some further testing. It seems that after the upgrade to V4.2, any app service call where I am passing "" (empty/null) for a property, regardless if it is marked as required or not, the ABP validation error happens. The error message is always the same one as shown below, in both solutions.

    "The following errors were detected during validation.↵ - ↵"
    

    I get the same error message in both my projects, the ASPNETZERO solution and the open source ABP template solution.

    Is there some breaking change in the V4.2 version?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @exlnt,

    If this is ASP.NET CORE, then your usage is not allowed from the beginning. But if it is ASP.NET MVC 5.x, ABP framework started to use validaiton of WebAPI and probably because of that you are getting these errors.

    We can offer you a solution according to your version (ASP.NET Core ır MVC 5.x ).

    Thanks.

  • User Avatar
    0
    exlnt created

    <cite>ismcagdas: </cite> Hi @exlnt,

    If this is ASP.NET CORE, then your usage is not allowed from the beginning. But if it is ASP.NET MVC 5.x, ABP framework started to use validaiton of WebAPI and probably because of that you are getting these errors.

    We can offer you a solution according to your version (ASP.NET Core ır MVC 5.x ).

    Thanks.

    I am running the MVC5.x solution in one project and ASP.Net core in the other solution. So I will need both. :D

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @exlnt,

    I think you need to fix the problems you have found by sending the correct parameter. There was a change in ABP framework for Web API but I couldn't find the issue number at the moment.

  • User Avatar
    0
    exlnt created

    My code was working perfectly before the V4.2 upgrade.

    If I cannot use "" for the seed value of dropdowns what can I use? I cannot implement "0" in every dropdown as that created FK violations when, on an optional property, the user does not choose a value. Again, this was all working just fine before upgrade.

    Can you at least tell me what has changed in the new version that is breaking my code?

    How do I debug the validation code, where is the source code for the ABP validation that happens? At least this way i can see the root cause of the issue.

  • User Avatar
    0
    exlnt created

    <cite>alper: </cite> The rendering is done in this javascript file jquery.jtable.record-actions.js So it must be included in your layout. Can you check it?

    Today, I tried working on the .Net Core 1.1 MVC template again. Once again, I am having the same issue with DataTables grids, my action column is NOT displaying at all. It works fine on the pages provided in the template, like roles and tenants grids. But on my custom Index grids, using datatables, my action column is not rendering at all. The code from the script datatables.record-actions.js is not firing on my custom index views.

    Do I need to explicitly reference this script in each of my index views?

    I debugged the issue little further, by adding break statement in the DataTables.record-actions.js script. On the pages for roles & tenants the script is working and going into the methods to render the actions column and button. But for my custom entities and it never hits the methods to render actions. The user who I am testing with has ALL permissions granted so I have confirmed that part. Example showing the render working for the Roles index view: <a class="postlink" href="https://drive.google.com/file/d/0B5HAoiVVXzY7b29leXR5Mk0zWEE/view?usp=sharing">https://drive.google.com/file/d/0B5HAoi ... sp=sharing</a>

    For my custom index views that code never gets executed.

  • User Avatar
    0
    exlnt created

    Ok the validation issue happened again today in my .NET Core MVC solution.

    Chrome console showing validation error: <a class="postlink" href="https://drive.google.com/file/d/0B5HAoiVVXzY7Z0JTSjV6MW1YVFU/view?usp=sharing">https://drive.google.com/file/d/0B5HAoi ... sp=sharing</a>

    Chrome console showing app service posted values: <a class="postlink" href="https://drive.google.com/file/d/0B5HAoiVVXzY7Y0tPWjFXT3JKRkE/view?usp=sharing">https://drive.google.com/file/d/0B5HAoi ... sp=sharing</a>

    As you can see on that screenshot, the field "CompanyRegNumber" is clearly provided on the form. Yet the validation is still firing and reporting that field with that same generic error message? There has to be some issue here? Please help me find it!

    Another strange issue here. This issue happens on and off. If I keep testing the same create method over and over again, one fails immediately try the exact same one again, using all the same values and it works! I feel like I am going crazy here or living in the twilight zone!! :o :D

    Aug 8: Here is one more example of the same validation error in my other project, using just the open source ABP template with BSB Admin template. <a class="postlink" href="https://drive.google.com/file/d/0B5HAoiVVXzY7U2QxblhTTGFhMnc/view?usp=sharing">https://drive.google.com/file/d/0B5HAoi ... sp=sharing</a>

  • User Avatar
    0
    exlnt created

    I <span style="color:#FF0000">solved </span>my datatables action column issue. It looks like there is bug in the JS code in script <span style="color:#FF0000">datatables.record-actions.js</span>. Any time you only have one action on the action dropdown it wont render the action column. I fixed it by updating this line of code: <span style="color:#FF0000">if (field.items && field.items.length > 0)</span>

    var _createRowAction = function (record, field, tableInstance) {
            //20170808 - Fixed IF to check for GT 0, instead of 1
           if (field.items && field.items.length > 0) 
                return _createButtonDropdown(record, field, tableInstance);
            } else if (field.element) {
                var $singleActionButton = _createSingleButton(record, field);
                if ($singleActionButton != "") {
                    return $singleActionButton.clone(true);
                }
            }
    
            return "";
        }
    

    One other related issue, the basic datatable call, shown below, is not working. I end up with a empty table with "loading" displayed.

    $('#tblNotes').DataTable();
    

    How do I initialize a basic datatable?

    Also, prior to the V4.X upgrade I was using Editable DataTables. I copied the code/examples directly from Metronic source files. They were all working perfectly. Now in the ASPNETZERO V4.X versions, they are not working. Is there some custom code implemented for Datatables by ASPNETZERO solution?

  • User Avatar
    0
    alper created
    Support Team

    hi

    You can track the Datatables issue from the below link <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/issues/367">https://github.com/aspnetzero/aspnet-ze ... issues/367</a>

    If we determine any bug, it'll be fixed in the next release.

  • User Avatar
    0
    alper created
    Support Team

    For initializing a basic datatable you can read the related jquery library documents.

    <a class="postlink" href="https://datatables.net/">https://datatables.net/</a>

  • User Avatar
    0
    exlnt created

    The code I showed above is how to initialize a basic datatables. I have done this many times and it was working fine. It is not working inside the aspnetzero solution.

    Please read my recent posts on this thread. The validation issue is happening across all variations of the aspnetzero templates. I feel like I am just talking to myself on this thread lately. I'm not really getting any support!

  • User Avatar
    0
    alper created
    Support Team

    Hello,

    It's not true that you are not really getting any support! Below are some quotes by you from this topic;

    _<span style="color:#A7AAB1">By exlnt : Thank you very much! That script was missing from the BundleConfig.cs file! Its working now!

    By exlnt : One more question/issue. Is there some breaking change for how the Index view app services work in v4.1? All but one of my existing app services for index views is breaking. It seems to happen, mainly, on the index views where I have filters. It keeps failing with validation error messages?

    By exlnt : @ismcagdas - Thanks very much! Better late than never

    By exlnt : One further question/help needed. I am still getting this validation error on some of my modal actions. Is there a way where I can debug the built-in ABP automatic validation that happens? </span>_

    Forum topics are designed one topic for one issue. As I can see you got support from the team on different issues on this topic.


    And for initializing datatables; there are several pages you can use as template. but basically below is the min code to show datatables data. if it still doesn't work for you, you may check your own modifications and you believe there's a problem in the template, share your solution with <a href="mailto:[email protected]">[email protected]</a> to have us understand your issue.

    <table id="MyBasicDatatable" class="display table table-striped table-bordered table-hover dt-responsive nowrap">
    	<thead>
    		<tr>
    			<th>My Field</th>
    		</tr>
    	</thead>
    </table>
    
    $('#MyBasicDatatable').DataTable({
                paging: false,
                listAction: {
                    ajaxFunction: _yourApiService.yourApiMethod
                },
                columnDefs: [               
                    {
                        targets: 0,
                        data: "myField"
                    }
                ]
            });
    
    Response from app service should be similar to this => [{myField:'test-1'}, {myField:'test-2'}];
    
  • User Avatar
    0
    exlnt created

    I was referring to my last few posts on this thread. I was not getting any response to my issues. In general you do provide support.

    I did not open new thread as issue was somewhat related.

    I still don't have an answer on my validation issue I posted here. Let me know if you want me to post new thread for it?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @exlnt,

    Sorry for the late response. Can you share input dto for UpdateCountry method ? We will check it.

    Thanks.

  • User Avatar
    0
    exlnt created

    <cite>ismcagdas: </cite> Hi @exlnt,

    Sorry for the late response. Can you share input dto for UpdateCountry method ? We will check it.

    Thanks.

    @ismcagdas - Thanks very much for following up on this thread, I really do appreciate it! I was able to find errors in my log files that helped me find root cause of the validation errors. There was a conversion failure happening in JSON.Net.

  • User Avatar
    0
    ismcagdas created
    Support Team

    @exlnt good to know :)

    Thanks.