문제

dojox.grid.DataGrid에 htmlStore 테이블의 데이터를 표시하고 있습니다.일부 데이터 셀에 HTML 콘텐츠(앵커 - a href)를 갖고 싶습니다.htmlStore 테이블의 앵커를 하드코딩해 보았지만 확실히 이는 매우 비효율적이었습니다.

htmlStore를 사용하라는 지시를 받았습니다.내가 선호하는 것은 ItemFileWriteStore를 사용하는 것이었고, 그러면 연결된 json 파일에 URL을 하드 코딩할 수 있었습니다.

아래의 레이아웃 코드.미리 감사드립니다!


            dojo.require("dojox.data.HtmlStore");
            dojo.require("dojox.grid.DataGrid");
                // set the layout structure:
                var layoutDash = [

                [{
                    field: 'Order ID',
                    name: 'Order ID',
                    width: '56px'
                },
                {
                    field: 'Opportunity ID',
                    name: 'Opportunity ID',
                    width: '110px'
                },
                {
                    field: 'Opportunity Name',
                    name: 'Opportunity Name',
                    width: '170px'
                },
                {
                    field: 'Customer',
                    name: 'Customer',
                    width: '210px'
                },
                {
                    field: 'Sales Rep',
                    name:  'Sales Rep',
                    width: '80px'
                },
                {
                    field: 'Stage/Status',
                    name:   'Stage/Status',
                    width:  '100px'
                },
                {
                    field: 'Last Modified',
                    name:  'Last Modified',
                    width: '90px'
                },
                {   
                    field: 'Actions',
                    name:  'Actions',
                    width:  'auto',
                    editable: 'true'
                }]];
도움이 되었습니까?

해결책

해결되었습니다.포맷터 "actionsURL"을 생성하고 이를 Grid.cell에 추가했습니다.


    {   
        field: 'Actions',
        name:  'Actions',
        width:  'auto',
        editable: 'true',
        formatter: actionsUrl
    }]];

그런 다음 레이아웃 코드 아래에 기능을 추가했습니다.

중요한.이 기술을 사용하려는 경우 다음을 읽으십시오.반환된 값 "Edit"을 작은따옴표로 캡슐화하는 html 앵커가 있어야 합니다.내 데모 코드에는 표시되지 않습니다.

                  
        function actionsUrl() {
            return 'Edit';
        }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top