Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create function for populate #2

Open
newerton opened this issue May 12, 2016 · 5 comments
Open

Create function for populate #2

newerton opened this issue May 12, 2016 · 5 comments

Comments

@newerton
Copy link

This popular feature table dynamically with new values.

var sheetData = [
        [1,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0],
        [0,1,0,0,1,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0],
        [0,1,0,0,1,0,1,0,1,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0],
        [0,1,0,0,1,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0],
        [0,1,0,0,1,0,1,0,1,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
        [1,1,1,0,1,0,1,0,1,1,1,0,1,1,1,0,1,1,1,0,0,0,0,0],
        [1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0],
        [1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,0,1,0,0,0,0,0,0],
        [0,0,1,0,1,0,1,0,1,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0],
        [1,1,1,0,1,0,1,0,1,1,1,0,1,1,1,0,0,1,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]
    ];

sheet.setSheetData(sheetData);
@lbbc1117
Copy link
Owner

@newerton
Sorry I don't get this one

@newerton
Copy link
Author

@lbbc1117
I did a primary adaptation! :)

var CSheet = function (opt) {
...
    this.setSheetData = function (cellIndex) {
        var rowCount = cellIndex.length;
        var colCount = cellIndex[0] ? cellIndex[0].length : 0;
        var settingArea;

        for (var row = 0; row < rowCount; ++row) {
            for (var col = 0; col < colCount; ++col) {
                if (cellIndex[row][col] === 1) {
                    settingArea = {
                        startCell: [row, col],
                        endCell: [row, col]
                    };
                    sheetPrivate.areaOperate(settingArea, {type: "set", state: 1});
                }
            }
        }
    };
...
}
...
var publicAPI = {
...
    setSheetData: function (cellIndex) {
        sheetModel.setSheetData(cellIndex);
        removeSelecting();
        repaintSheet();
        return;
    },
...
};
 var sheetData = [
    [1,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0],
    [0,1,0,0,1,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0],
    [0,1,0,0,1,0,1,0,1,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0],
    [0,1,0,0,1,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0],
    [0,1,0,0,1,0,1,0,1,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0],
    [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
    [1,1,1,0,1,0,1,0,1,1,1,0,1,1,1,0,1,1,1,0,0,0,0,0],
    [1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0],
    [1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,0,1,0,0,0,0,0,0],
    [0,0,1,0,1,0,1,0,1,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0],
    [1,1,1,0,1,0,1,0,1,1,1,0,1,1,1,0,0,1,0,0,0,0,0,0],
    [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]
];

$('#J_timingPopulate').click(function(){
    sheet.setSheetData(sheetData);
});

@lbbc1117
Copy link
Owner

@newerton
Yeah right. A dynamic data setter for all cells.

@newerton
Copy link
Author

newerton commented May 12, 2016

@lbbc1117
It would be great to create a function to add 1 cell.

setSheetCell([2,3]);
setSheetCell([8,1]);

@lbbc1117
Copy link
Owner

lbbc1117 commented May 12, 2016

@newerton
Good advices friend. As I'm busy learning deep learning recently, I may do some modification if I get time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants