Open Closed

Unbound Column with lookup value #8081


User avatar
0
Navneet@aol.com.au created

Check the docs before asking a question: https://abp.io/docs/latest Check the samples to see the basic tasks: https://abp.io/docs/latest/samples The exact solution to your question may have been answered before, and please first use the search on the homepage. Provide us with the following info: 🧐 Hint: If you are using the ABP Studio, you can see all the information about your solution from the configuration window, which opens when you right-click on the solution and click on the Solution Configuration button.

  • ABP Framework version: v8.2.3
  • UI Type: MVC
  • Database System: EF Core (MySQL.)
  • Tiered (for MVC) or Auth Server Separated (for Angular): no
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

Hello ABP team,

I have a value in my list view, which I am trying to look-up with an unbound list in javascript, however it is not working, could you please help me with this code:

{ data: "licenseTypeId",
                render: function(licenseTypeId)
                {
                    var newresult;
                    window.techDB.baseLicense.licenseSubscriptions.licenseSubscription.getLicenseTypeLookup()
                    .then(function(licenseTypes){
                        var licenseType = licenseTypes.items.find(type => type.id === licenseTypeId);
                        newresult = licenseType.licenseName;
                        return licenseType;
                    });
                    return newresult;
                }
             } 

full code for datatable is :

var dataTableColumns = [
        {
            rowAction: {
                items:
                    [
                        {
                            text: l("Edit"),
                            visible: abp.auth.isGranted('BaseLicense.LicenseSubscriptions.Edit'),
                            action: function (data) {
                                editModal.open({
                                 id: data.record.id
                                 });
                            }
                        },
                        {
                            text: l("Delete"),
                            visible: abp.auth.isGranted('BaseLicense.LicenseSubscriptions.Delete'),
                            confirmMessage: function () {
                                return l("DeleteConfirmationMessage");
                            },
                            action: function (data) {
                                licenseSubscriptionService.delete(data.record.id)
                                    .then(function () {
                                        abp.notify.success(l("SuccessfullyDeleted"));
                                        dataTable.ajax.reloadEx();;
                                    });
                            }
                        }
                    ]
            },
            width: "1rem"
        },
		{ data: "licenseKey" },
        {
            data: "isActive",
            render: function (isActive) {
                return isActive ? '<i class="fa fa-check"></i>' : '<i class="fa fa-times"></i>';
            }
        },
	{   data: "licenseTypeId",
            render: function(licenseTypeId)
            {
                var newresult;
                window.techDB.baseLicense.licenseSubscriptions.licenseSubscription.getLicenseTypeLookup()
                .then(function(licenseTypes){
                    var licenseType = licenseTypes.items.find(type => type.id === licenseTypeId);
                    newresult = licenseType.licenseName;
                    return licenseType;
                });
                return newresult;
            }
         }      
];

Many thanks, Navneet


15 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Could you please share a minimal reproducible project with me? I will check it. shiwei.liang@volosoft.com

  • User Avatar
    0
    Navneet@aol.com.au created

    Hi Shiwei,

    I have sent you a sample when you run the project, first, create an author, note down the author's Guid Id second, create a book and add name and above Guid Id.

    the expected result when you the project and navigate to Booklist view, you should be able to see "Book Name", "Author ID" and "AuthorName".

    Sorry I am not good at Javascript (I am dotnet developer).

    Thanks Nav

  • User Avatar
    0
    Navneet@aol.com.au created

    Hi Shiwei,

    looks like I am not able to send you an email due to a bounce back with the below error:-

    Sorry, we were unable to deliver your message to the following address.
    <shiwei.liang@volosoft.com>:
    552: 5.7.0 This message was blocked because its content presents a potential
    5.7.0 security issue. To review our message content and attachment content
    5.7.0 guidelines, go to
    5.7.0  https://support.google.com/mail/?p=BlockedMessage d75a77b69052e-4607b4c88f0si7119331cf.597 - gsmtp
    
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can share it with https://wetransfer.com/

  • User Avatar
    0
    Navneet@aol.com.au created

    Hi Liangshiwei,

    I have sent you another email with a link to download

    many thx, Nav

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    because the HTTP Request is async. you can try this

    //<suite-custom-code-block-1>
    
    var _authors;
    window.acme.bookStore.books.books.getAuthorLookup()
    .then(function(authors){
        _authors = authors;
    });
    
    //</suite-custom-code-block-1>
        
    .........
    
    { data: "authorName",
        render: function(authorID)
        {
            return _authors.items.find(type => type.id === authorID).firstname;
           
        }
     }         
    
  • User Avatar
    0
    Navneet@aol.com.au created

    Thanks Liangshiwei, it is not giving the result I am looking for, it is just repeating the same author-name

    Liangshiwei, is there a way I can ignore JavaScript and use c# to display the book list view? As in c#, there is a for each loop that I can use to look at the Author.

    I tried to check ABP-Samples in MVC; all are using JavaScript to show a list view

    Many thx, Navneet

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Liangshiwei, is there a way I can ignore JavaScript and use c# to display the book list view? As in c#, there is a for each loop that I can use to look at the Author.

    Yes, you can check this document:

    https://abp.io/docs/latest/suite/generating-crud-page#step-by-step-creating-a-navigation-property-with-1-to-many-relat

  • User Avatar
    0
    Navneet@aol.com.au created

    Hi Liangshiwei,

    Sorry if I am not very clear, but

    1. It's not a bound column as one-to-many navigation
    2. When I use Suite, it creates code in Javascript for list view, not c#
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    When I use Suite, it creates code in Javascript for list view, not c#

    yes, Suite always uses JS to load the view because the list needs to be loaded asynchronously .

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Thanks Liangshiwei, it is not giving the result I am looking for, it is just repeating the same author-name

    This is because the look-up result doesn't have ID property

    Add ID to AuthorLookupDto

    Update JS

    render: function(data, type, row, meta)
    {
        return _authors.items.find(type => type.id === row.authorID).firstname;
       
    }
    

  • User Avatar
    0
    Navneet@aol.com.au created

    Many thx Liangshiwei,

    Javascript is now working 😀

    I wonder if ABP.io will look to develop c# based asynchronously so that it can be fully c# based same as what ABP suite creates code for CreateModel and UpdateModel.

    Thanks again Navneet

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I wonder if ABP.io will look to develop c# based asynchronously so that it can be fully c# based same as what ABP suite creates code for CreateModel and UpdateModel.

    Unfortunately not, because the table needs to refresh and search, need to use js to operate DOM

  • User Avatar
    0
    Navneet@aol.com.au created

    Thanks for your help.

    We can close this ticket.

    Quick question: I am getting an error while downloading IdentityServer.Pro module: I know it is discontinued however, one of my clients is still using it

    **abp get-source Volo.Abp.IdentityServer.Pro**
    
    [22:37:18 ERR] Downloading source code failed for: Volo.Abp.IdentityServer.Pro
    Volo.Abp.Studio.AbpStudioException: Exception of type 'Volo.Abp.Studio.AbpStudioException' was thrown.
      at async Task Volo.Abp.Studio.Modules.Installing.SourceCodeDownloader.DownloadSourceCodeAsync(string          
         moduleName, string targetFolder, string version, bool includeNightly)                                      
      at async Task Volo.Abp.Studio.Cli.Commands.StudioGetSourceCommand.ExecuteAsync(CommandLineArgs commandLineArgs
         )                                                                                                          
      at async Task Volo.Abp.Studio.Cli.StudioCliService.RunInternalAsync(CommandLineArgs commandLineArgs)          
      at async Task Volo.Abp.Studio.Cli.StudioCliService.RunAsync(string[] args)  
    

    Thanks, Bye

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Quick question: I am getting an error while downloading IdentityServer.Pro module: I know it is discontinued however, one of my clients is still using it

    It looks like a problem, we will fix it soon.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09