문제

Zend 프레임 워크 프로젝트에서 간단한 Dojo Datagrid로 고군분투하고 있습니다.

표시 할 수있는 MySQL 테이블의 데이터 목록이 있지만 사용자가 선택한 행을 제거하고 DB에서 제거 할 수 있기를 원합니다. 나는 예제를 사용하고 있습니다 DOJO DATAGRID 데이터 추가 및 삭제. Datagrid에 대한 내 견해에 내 코드는 다음과 같습니다.

<div dojoType="dojo.data.ItemFileReadStore" jsId="skillstore" url="<?php echo $this->baseUrl()?>/skills/hist/<?php echo $this->histid;?>"></div>

<table id="skillgrid" jsId="skills" dojoType="dojox.grid.DataGrid" store="skillstore"   style="height:300px;width:500px;">
 <thead>
    <tr>
        <th field="skillid" hidden="true"></th>
        <th width="auto" field="skill">Skills</th>
    </tr>

</thead>
</table>
<div>
<button dojoType="dijit.form.Button" onclick="removeRows()" >Remove Selected Row</button>
<button dojoType="dijit.form.Button" onclick="addRow()">Add another skill</button>
</div>

View Scripts Capturestart 및 캡처 태그 사이에서 행을 제거하기위한 코드를 배치했습니다. Remowerows ()의 코드는 다음과 같습니다.

function removeRows(e){     
    var items = skillsgrid.selection.getSelected();

    if(items.length){

        dojo.forEach(items, function(selectedItem){

            if(selectedItem !== null){

                skillstore.deleteItem(selectedItem);
            }//endif
        });//end foreach

    }//end if
}

내가 얻는 주요 문제는 행을 선택하고 버튼을 클릭하면 Firebugs가 SkillStore.deleteitem이 기능이 아니라고 불평한다는 것입니다. 아직 데이터베이스에서 항목을 제거하려고 시도하지 않았습니다.

모든 포인터는 대단히 감사 할 것입니다.

도움이 되었습니까?

해결책

나는 당신이해야 할 일은 jsId 속성 값은 id 하나:

var items = skills.selection.getSelected();

편집하다:

그래도 작동하지 않으면 마감 직후 다음을 추가 했습니까? body 꼬리표?

<script type="text/javascript" src="dojo.js" djConfig="parseOnLoad: true">
</script>
<script type="text/javascript">
    dojo.require("dojox.grid.DataGrid");
    dojo.require("dojo.data.ItemFileWriteStore");
    dojo.require("dijit.form.Button");
</script>

edit2:

실제로 읽기 전용 저장소를 사용하고 있습니다. 이것이 문제입니다.

다른 팁

이것들은 내가 할 것입니다.

dojo.require 선언 ( "dojo.data.itemfilewritestore"); 필수이다. 그렇기 때문에 Firebugs는 SkillStore.deleteitem이 'ItemFileWritestore'에 'deleteitem'이 없기 때문에 SkillStore.deleteitem이 함수가 아니라고 불평합니다.

function removeRows(e){         
        var items = skillsgrid.selection.getSelected();
        if(items.length){
                dojo.forEach(items, function(selectedItem){
                      skillsgrid.store.deleteItem(selectedItem); 
                      skillsgrid.sort(); // I did access the store of the grid directly.
                });//end foreach

        }//end if
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top