2012-10-04 2 views
16

Kendo Grid에 변경 사항이 있는지 어떻게 확인할 수 있습니까? dirty 속성이 있다고 들었지만 찾을 수 없습니다.검도 그리드가 변경되었는지 어떻게 확인합니까?

+0

'batch : true '를 설정하면 변경이 발생할 때마다이를 나타내는'change' 이벤트가 있습니다 . –

+0

hasChanges() 함수가 작동하거나 dataItem에 더티 속성을 표시하려면 dataSource 스키마를 정의해야합니다. – Misi

답변

16

추가 된 행은 dirty 속성이 true로 설정되어 업데이트 된 행을 갖게됩니다. 그러나 삭제 된 행은 _destroyed 컬렉션의 다른 위치에 저장됩니다. 이 함수에 그리드의 데이터 소스를 전달하여 변경 사항이 있는지 확인하십시오.

function doesDataSourceHaveChanges(ds) 
{ 
    var dirty = false; 

    $.each(ds._data, function() 
    { 
     if (this.dirty == true) 
     { 
      dirty = true; 
     } 
    }); 

    if (ds._destroyed.length > 0) dirty = true; 

    return dirty; 
} 
8

당신은///업데이트를 읽을 레코드를 삭제 통보하고 페이지/분류/그룹/필터/만들 때마다 발생합니다은 dataSource의 변경 이벤트를 사용할 수 있습니다.

은에 대한 핸들러가 사용 연결하려면 :

$('#YourGrid').data().kendoGrid.dataSource.bind('change',function(e){ 
    //the event argument here will indicate what action just happned 
    console.log(e.action)// could be => "itemchange","add" or "remove" if you made any changes to the items 
}) 

업데이트 : 사용자가 모델 .hasChanges 중 하나를 업데이트 한 경우() DataSource에 방법을 true를 돌려줍니다.

1

가치가 시도 :

var hasDirtyRow = $.grep(gridDataSource.view(), function(e) { return e.dirty === true; }); 
if (hasDirtyRow.length != 0) 
{ 
    // grid has dirty row(s) 
} 
26

당신은 그리드의 기본 데이터 소스의 'hasChanges'방법을 사용할 수 있습니다 : 데이터 소스가 변경된 경우

grid.dataSource.hasChanges(); 

$('#divGrid').data('kendoGrid').dataSource.hasChanges(); 
+0

속성 값을 업데이트하면이 작업이 수행되지 않습니다. 그거야? – Gayan

3

grid.dataSource.hasChanges 당신이 알려 드릴 것입니다

      if (datasource.hasChanges() === true) { 
           alert('yes'); 
          } else { 
           alert('no'); 
          } 
관련 문제