-3

我可以使用 getState() 来获取网格列标题名称(可见名称)吗?

4

1 回答 1

0

不。但是这个非常复杂的函数会将它们作为数组返回给你:

function getGridClipboardText(grid){
        var columns = grid.columns,
            headerData = [],
            subHeaderData = [],
            dataIndex = [],
            du = Sms.dataUtilities,
            columnCount = columns.length,
            startIndex = 0,
            headerText,
            subColumnCount,
            visibleSubColumns,
            columnCollection,
            i, j, col, subCol;

        // If grid has a row expander plugin, skip the first column
        if(grid.expanderDataIndex){
            startIndex = 1;
        }

        // Collect the header titles
        for(i = startIndex; i < columnCount; i++){
            col = columns[i];
            if(!col.hidden){
                headerText = du.getInnerHtml(col.text);

                // Flatten the data index references to a single array
                if(col.dataIndex){
                    dataIndex.push({
                        dataIndex: col.dataIndex,
                        clipboard: col.clipboard
                    });
                }

                // If the column has sub-columns, handle them
                // IMPORTANT: This function only supports two levels of headers.
                // When upgrading to fully-nested headers, use a recursive algorithm.
                if(col.items && col.xtype !== "actioncolumn"){
                    if(Ext.isArray(col.items)){
                        columnCollection = new Ext.util.MixedCollection(false);
                        columnCollection.addAll(col.items);
                    }
                    else{
                        columnCollection = col.items;
                    }

                    subColumnCount = columnCollection.getCount();
                    visibleSubColumns = 0;
                    for(j = 0; j < subColumnCount; j++){
                        subCol = columnCollection.getAt(j);
                        if(!subCol.hidden){
                            visibleSubColumns++;
                            subHeaderData.push(du.getInnerHtml(subCol.text));

                            if(subCol.dataIndex){
                                dataIndex.push({
                                    dataIndex: subCol.dataIndex,
                                    clipboard: col.clipboard
                                });
                            }
                        }
                    }

                    // If there are no sub-columns, but there could be, create a spacer
                    // in the array to keep everything lined up
                    if(subColumnCount === 0){
                        subHeaderData.push("");
                    }

                    // Pad the main header with extra tabs to account for the sub-columns
                    for(j = 0; j < visibleSubColumns - 1; j++){
                        headerText += "\t";
                    }
                }

                headerData.push(headerText);
            }
        }

        return headerData;
    }
于 2012-06-29T16:26:27.810 回答