2013-08-01 20 views
0

我嘗試檢查表格列值,當他們失去焦點時。
我做了一個演示,以顯示和良好的容易理解。
這是鏈接。 http://jsbin.com/oqeral/16/edit
在這裏我嘗試檢查列值,如果它的真實然後網格刷新或其他任何東西。
但是當它的錯誤,那麼我想把重點放在最後一次聚焦場。
這裏是簡單的jquery。我編輯時間劍道網格。
我想在kendo設置網格列的焦點

edit: function(e) 
       { 
        $('table').find('tr').mouseover(function(){ 
        var row = $(this).find('td:eq(1)'); 
        var box = $(row).find('input'); 
        $(box).focusout(function(e){ 
        if($(box).val() == 'Hood') 
        { 
         alert('Its Hood'); 
        } 
         else 
         { 
         alert('Not Hood'); 
         } 
        }); 
        }); 
       } 

這裏是警戒值Hood然後從引擎蓋列失去焦點。
但如果Not Hood然後再次集中在發動機罩列。
我該怎麼做。在劍道網。
謝謝。

回答

1

您應該使用「保存」事件。

http://docs.kendoui.com/api/web/grid#events-save

所以你的情況

var t = $("#grid").kendoGrid({ 
    dataSource: { 
     data: users, 
     pageSize: 10 
    }, 
    pageable: true, 
    selectable: "multiple row", 
    toolbar: ["create"], 
    columns: [{ 
     field: "UserId" 
    }, { 
     field: "UserName" 
    }, { 
     field: "IsAdmin" 
    }, { 
     command: "destroy", 
     title: " ", 
     width: "100px" 
    }], 
    editable: true, 
    save: function (e) { 

     // here you have the name before edit 
     console.log('Name was: '+e.model.UserName); 
     // with e.values you have the new values the user gave 
     console.log('New name: '+e.values.UserName); 

     // if the user has not given 'Hood' as a name for example... 
     if(e.values.UserName!=='Hood'){ 
     // make your check and if you want to prevent saving you can do this for example 
     e.preventDefault(); 
     } 
    } 
}); 
+0

好工作。在某種程度上工作,但我想在條件下設置editCell()。 –

+0

這裏有一些我已經找到http://stackoverflow.com/questions/11851071/how-to-set-focus-to-cell-in-kendo-ui-for-mvc-grid –

+0

爲什麼提示用戶再次進入編輯模式?你可以給他一個信息,而不是讓他輸入你不接受的價值。所以你永遠不會離開這一行的編輯模式。它更快,更簡單。除非你想要別的事情。 – AntouanK