0

在我的网格中,我应该能够根据从 web 服务返回的状态来拥有复选框和字符串数据。现在我正在编写下面给出的自定义渲染器函数:函数 customcolumn1(值,元数据,记录){

    var completedTime = record.get('nccompletedTime');
    var completedByLastName = record.get('nccompletedByLastName');
    var completedByFirstName = record.get('nccompletedByFirstName');
    if (value == 'Completed') {
        return completedTime + " " + completedByLastName + "," + completedByFirstName;
    } else if (value == 'Pending') {
        return "<input type='checkbox' disabled>";
    } else if (value == 'Assigned') {
        return "<input type='checkbox'>";
    }
}

网格是

var SAFjobgrid = Ext.create('Ext.grid.Panel', {
    store: store,
    columns: [
        {
        text: "",
        width: 30,
        renderer: customSeqNumber,
        dataIndex: 'sequenceNumber'},
    {
        text: "Task",
        width: 350,
        renderer: customTask,
        dataIndex: 'label'},
    {
        text: "Complete",
        width: 160,
        renderer: customcolumn2,
        dataIndex: 'stampActionStatus'},
    {
        text: "Verified",
        width: 160,
        renderer: customcolumn,
        dataIndex: 'verifyActionStatus'},
    {
        text: "Non Compliance",
        flex: 1,
        renderer: customcolumn1,
        dataIndex: 'ncActionStatus'}

    ]
});

现在我想检查复选框并捕获这些记录的 stampIds。当我单击网格之外的更新按钮时,我应该能够使用捕获的 stampId 调用 web 服务。我尝试将 onclick 事件放在从渲染器功能返回时的复选框。但是我应该如何访问该记录的stampId。如果我选​​择多个复选框,多个stampid应该转到webservice,如果我取消选中该复选框,相应的stampid应该从stampId中删除。有人可以帮忙解决这个吗..

4

1 回答 1

0

您可以查看 CheckColumn 用户扩展http://docs.sencha.com/ext-js/4-1/#!/api/Ext.ux.CheckColumn但在您的情况下,您必须像这样覆盖渲染器方法

renderer : function(value, meta, record){
    var cssPrefix = Ext.baseCSSPrefix,
        cls = [cssPrefix + 'grid-checkheader'],
        completedTime = record.get('nccompletedTime'),
        completedByLastName = record.get('nccompletedByLastName'),
        completedByFirstName = record.get('nccompletedByFirstName');

    if (value == 'Completed') {
        //render string instead of checkbox
        return Ext.String.format('{0} {1},{2}', completedTime, completedByLastName, completedByFirstName);
    }

    if (value === 'Assigned') {
        cls.push(cssPrefix + 'grid-checkheader-checked');
    }
    //render checkbox stub, 
    //it is actually a div element with special css classes to simulate checkbox
    return '<div class="' + cls.join(' ') + '">&#160;</div>';
}

要收集所有选中/未选中的行,您可以使用此存储方法http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.AbstractStore-method-getUpdatedRecords 它返回模型数组通过选中/取消选中此列进行更新

于 2012-09-06T15:46:48.610 回答