0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Show Knowledge article (not Community related)

Last updated at Posted at 2021-06-01

面白い質問があったので、ちょっと回答してみました。

ナレッジとタブセットを使った画面です。
あんまりこんな使い方は考えたことがなかったです。

Show Knowledge article (not Community related)

ボタンのコンポーネントこれから、目的のコンポーネントをキックするようです。
ポイントは親コンポーネントから子コンポーネントを呼び出すところですね。
親から子なんでイベントは使っていません。

Menu 1 button

<aura:component implements="flexipage:availableForAllPageTypes,force:appHostable" access="global">
    <aura:attribute name="setMeOnInit" type="String" default="default value" />

    <lightning:button variant="brand-outline" label="Menu1" title="Menu 1 action" onclick="{! c.handleClick }"/>
    <p>This value is set in the controller after the component initializes and before rendering.</p>
    <p><b>{!v.setMeOnInit}</b></p>
    
    <c:MyArticleviewer aura:id="MyArticleviewer"  />
        
</aura:component>
({
	handleClick : function(component, event, helper) {
        
        var childCmp = component.find("MyArticleviewer");
        childCmp.onInit2(); 
	}
})

MyArticleviewer

<aura:component implements="flexipage:availableForAllPageTypes" access="global" controller="SampleAuraController">
    <aura:handler name = "init" value = "{!this}" action = "{!c.onInit}"/>
    <aura:attribute type="Knowledge__kav[]" name="articleList"/>
    <aura:attribute name="isOpen" type="Boolean" default="false"/>
    
    <aura:method name="onInit2">  
    </aura:method>
    
    <aura:if isTrue="{!v.isOpen}">
        <lightning:card>
            <lightning:tabset>
                <aura:iteration items="{!v.articleList}" var="item">
                    <lightning:tab label="{!item.Title}" id="{!item.Id}">
                        <lightning:recordForm
                                              recordId="{!item.Id}"
                                              objectApiName="Knowledge__kav"
                                              layoutType="Compact"
                                              mode="readonly" />
                    </lightning:tab>
                </aura:iteration>
            </lightning:tabset>
        </lightning:card>
    </aura:if>
</aura:component>
({
    onInit : function( component, event, helper ) {    
    },
    
    onInit2 : function( component, event, helper ) {    
        component.set( "v.isOpen","true" ); 
        let action = component.get( "c.fetchArticles" );  
        action.setCallback(this, function(response) {  
            let state = response.getState();  
            if ( state === "SUCCESS" ) {  
                
                console.log( "Returned value is " + JSON.stringify( response.getReturnValue() ) );
                component.set( "v.articleList", response.getReturnValue() );
                
                
            }  else {
                
                let showToast = $A.get( "e.force:showToast" );
                showToast.setParams({
                    title : 'Error',
                    type : 'error',
                    mode : 'sticky',
                    message : 'Some error occured'
                });
                showToast.fire();
                
            }
        });  
        $A.enqueueAction( action );         
        
    },
})

# その他

コミュニティで知識を共有する

Knowledge Articles Not Displaying Within Customer Portal
顧客プロファイルに移動し、「カテゴリグループの可視性設定」ですべてのカテゴリグループに表示する必要があります

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?