Open Closed

AUTOMATICALLY LOAD LOOKUP FORM #8747


0
alfar_re created

Hi,

Is it possible to automatically load a selection on the lookup form?

For example; I have a country lookup modal on my CreateOrEditEmployee form and I'd like to add a new employee under country 'Brazil' by clicking a link such that the CreateOrEditEmployee form loads with 'Brazil' selected.


10 Answer(s)
  • 0
    ismcagdas created
    Support Team

    Hi @alfar_re,

    Do you use Angular or jQuery ?

  • 0
    alfar_re created

    Hi @ismcagdas,

    I'm using jQuery

  • 0
    alfar_re created

    Hi,

    Needing resolution on this matter. Thank you.

  • 0
    ismcagdas created
    Support Team

    Hi,

    You can open a user lookup modal wherever you want using a sample code like below;

    var lookupModal = app.modals.LookupModal.create({
    	title: app.localize('SelectAUser'),
    	serviceMethod: abp.services.app.commonLookup.findUsers,
    	filterText: ''
    });
    
    lookupModal.open({}, function (selectedItem) {
    	// user select handle code.
    });
    
  • 0
    alfar_re created

    Hi,

    Thank you. Let me try this out.

  • 0
    ismcagdas created
    Support Team

    @alfar_re

    Let us know if that doesn't work.

  • 0
    alfar_re created

    Hi @ismcagdas,

    I have looked at this and am wondering how to implement it inside actions in index.js

  • 0
    ismcagdas created
    Support Team

    @alfar_re

    It is related to your use case. You can use this code where you need to opne the modal. If you can explain your use case and share the code of Index.js, we can help.

  • 0
    alfar_re created

    Hi @ismcagdas,

    My use case is simple. I have an entity Building an entity RentalUnits. One Building has many RentalUnits and on RentalUnit create modal there is Building as a navigation property. So, on the Building actions, I have 'Add Rental Unit' as an action which a user can use to add RentalUnits to a Building. This means that it makes sense to have the respective Building selected when the action is selected.

    See Index below;

    `var _createOrEditRentalUnitModal = new app.ModalManager({
    			viewUrl: abp.appPath + 'App/RentalUnits/CreateOrEditModal',
    			scriptUrl: abp.appPath + 'view-resources/Areas/App/Views/RentalUnits/_CreateOrEditModal.js',
    			modalClass: 'CreateOrEditRentalUnitModal'
    		});
    
    
         {
    			text: app.localize('Add Unit'),
    			action: function (data) {
    			_createOrEditRentalUnitModal.open({ buildingId: data.record.building.id });
    	}`
    

    Now, I'd like to know how to make this work with the code you shared on here.

    Thank you.

  • 0
    ismcagdas created
    Support Team