Retrieve rows in crm2011 subgrid with JScript

前端 未结 4 1035
眼角桃花
眼角桃花 2020-12-20 09:40

As an JScript newbie, I have a problem with a subgrid in MS CRM 2011.

I have a form with a subgrid and in OnSave of that form, I want to loop over all the rows in th

4条回答
  •  悲&欢浪女
    2020-12-20 10:25

    You can inspect the subgrid values on save by doing the following:

    var gridControl = document.getElementById('subgrid_id').control;
    var ids = gridControl.get_allRecordIds();
    for(i = 0; i < ids.length; i++) {
        var cellValue = gridControl.getCellValue('column_name', ids[i]);
        // logic
    }
    

    Doing this on load is a bit more challenging since subgrids are loaded asynchronously and aren't likely to be done loading when the form onload event fires. You can check the grid periodically though to see when it's done loading by calling a function like the following in your form onload:

    function subGridOnload() {
        var grid = document.getElementById('subgrid_id');
        if (grid.readyState!="complete") {
            // delay one second and try again.  
            setTimeout(subGridOnload, 1000);
            return;
        }
    
        // logic
    }
    

提交回复
热议问题