Possible to build a Excel-like Table
Posted: Wed Jan 18, 2017 4:48 pm
I am wondering if this is possible and I tried to get it working to some smaller degree.
The usual field can be table field with columns and rows and a grid can show their position.
Now I would like to enter and manage data as in an Excel spreadsheet - or at least kind of doing this.
Trying this and that and trying to study the dictionary, and some messages here, I found that a lot depends on how keyboard entries are detected and then used inside the field.
I am working on Windows and I do not know anybody who works with Apple machines on the. So, priority is Windows in my environment, and I want to eventually have this also done for other users if LC allows me.
Is there anybody who can help?
What did I do so far? I want to enter a field but the "cell edit" that is provided does not work well, and it is not what I want.
It should be possible to:
1. Enter any "field" or cell of the spreadsheet at any time, and this entry must visually represent itself.
2. Using shiftkey-tab I want to move from cell to cell backwards. Tabbing moves forwards, return keys move to the next row in the same column (or beginning of the next row), and shift-return goes up to the previous row.
3. The deletion of data using the back key must not delete anything that is not in the cell itself. So, it does not delete tab keys or returns.
4. Hitting control-return will create a new row if there is not a grid with any number of rows already.
5. Depending on the type of data (text, dates, numbers, decimals) the column will format itself, or an individual field is formatted.
6. It would be ideal if columns and rows can be hilited as a row or column. Also, more than one column or row should be hilited. Also - if possible - discontinuous parts of the spreadsheet. This is not first priority, but a "nice to have". And selected areas should allow for certain operations: changing columns, deleting columns, adding columns, formatting columns, etc.
8. I would like to have a cell fully hilited with whatever color is chosen, not just the text string inside of it. Currently this does not look idea if the text inside a cell is hilited. I do not know how to accomplish this yet using the formatting capabilities for table-like fields.
8. There could eventually be a mode to edit formulas, but users are not using this even in Excel and it is not needed.
The main purpose is for data entry. People like to enter visually into a list directly into the new row after the last row, or into the first row before all other rows. And I like this too.
To some degree, I get control over list cells detecting rawkey and key messages (on rawkeyup, on rawkeydown and keydown and - up messages) and preventing deletion of characters that should not be deleted. But it does not "feel" as slick as it should be. I do not know what would be the best for really controlling the behavior to its full extend.
For example, I came up with:
on rawkeydown myKey
if myKey is 65289 then -- tab key
put tab after me
else if myKey = 65288 -- back key
delete last char of me
else
pass rawkeydown
end if
end rawkeydown
But I could not yet figure out how to prevent the deletion of tabs and returns. And also I could not yet find a way of using shift-tab while also preventing undesired deletions.
Is there any documentation about how to work with all available functions and properties regarding fields and text - not just to have to look through the dictionary to find out and do a lot of trial and error?
This would also include the visual properties such as margins, lineheight etc. There is something, but I do not fully understand all the possibilities yet.
Then maybe someone has already done this?
Another way I was thinking - but I am not sure about it. If I forget about any tables and lists (not speaking of the datagrid anyway), would it make sense using individual feels which are put together as rows, and each row could be a group for example.
Then I can clone the row group and add it to the bottom of the previous row. Or i can create a number of rows which then look like a spreadsheet and have people enter into these pseudo cells. And users can add more such rows as they like.
The advantage would be that cells are actually fields, and it is probably easier to manage everything.
What I did was some tests: Each field has a cell name such as "F_1_1", "F_1_2" etc. So the first item indicates the position in a row, the second item the position of the column. Then I can use variables. Let us say, I have a variable tRow, and a variable tCol. It does not work using "F_" & tRow &"_"& tCol directly addressing such one field. But if I put it the following way:
Code snippet:
put "F_" &tRow& "_" &tCol into fName
put "Hello" into field fName
This works really nicely.
And I can change the properties such as alignment, color, width, etc.
So, using a repeat loop, I can change the size of one column with all fields of that column and even make it be another column, swapping columns, creating new ones, deleting columns, inserting them, reformatting them, etc.
-- tRow = number of rows
-- tCol = number of columns
repeat with i = 1 to tRow
repeat with j = 1 to tCol
put "F_" & tRow & "_" & tCol into fName
-- do something with field f Name
end repeat
end repeat
Well, I imagine this leads to quite many functions, especially if this should work based on what the user is doing with each action recalculating everything.
For some rows and columns this might be fine, but what about data with 100, or 1,000 or 10,000 rows? I think then it will become too slow.
Maybe I am thinking in the wrong direction? I would like to be corrected here if this is the case.
I looked at the Datagrid, but I can not see (yet) how to customize it to have such functionality as I would like to have. And it uses arrays which I do not master yet in LC. But maybe I should consider them rather than possibly reinventing the wheel? Datagrid is a bit confusing to me. And I imagine I must spend at least a weekend to understand parts of it.
Any direction is HIGHLY welcome, please...
The usual field can be table field with columns and rows and a grid can show their position.
Now I would like to enter and manage data as in an Excel spreadsheet - or at least kind of doing this.
Trying this and that and trying to study the dictionary, and some messages here, I found that a lot depends on how keyboard entries are detected and then used inside the field.
I am working on Windows and I do not know anybody who works with Apple machines on the. So, priority is Windows in my environment, and I want to eventually have this also done for other users if LC allows me.
Is there anybody who can help?
What did I do so far? I want to enter a field but the "cell edit" that is provided does not work well, and it is not what I want.
It should be possible to:
1. Enter any "field" or cell of the spreadsheet at any time, and this entry must visually represent itself.
2. Using shiftkey-tab I want to move from cell to cell backwards. Tabbing moves forwards, return keys move to the next row in the same column (or beginning of the next row), and shift-return goes up to the previous row.
3. The deletion of data using the back key must not delete anything that is not in the cell itself. So, it does not delete tab keys or returns.
4. Hitting control-return will create a new row if there is not a grid with any number of rows already.
5. Depending on the type of data (text, dates, numbers, decimals) the column will format itself, or an individual field is formatted.
6. It would be ideal if columns and rows can be hilited as a row or column. Also, more than one column or row should be hilited. Also - if possible - discontinuous parts of the spreadsheet. This is not first priority, but a "nice to have". And selected areas should allow for certain operations: changing columns, deleting columns, adding columns, formatting columns, etc.
8. I would like to have a cell fully hilited with whatever color is chosen, not just the text string inside of it. Currently this does not look idea if the text inside a cell is hilited. I do not know how to accomplish this yet using the formatting capabilities for table-like fields.
8. There could eventually be a mode to edit formulas, but users are not using this even in Excel and it is not needed.
The main purpose is for data entry. People like to enter visually into a list directly into the new row after the last row, or into the first row before all other rows. And I like this too.
To some degree, I get control over list cells detecting rawkey and key messages (on rawkeyup, on rawkeydown and keydown and - up messages) and preventing deletion of characters that should not be deleted. But it does not "feel" as slick as it should be. I do not know what would be the best for really controlling the behavior to its full extend.
For example, I came up with:
on rawkeydown myKey
if myKey is 65289 then -- tab key
put tab after me
else if myKey = 65288 -- back key
delete last char of me
else
pass rawkeydown
end if
end rawkeydown
But I could not yet figure out how to prevent the deletion of tabs and returns. And also I could not yet find a way of using shift-tab while also preventing undesired deletions.
Is there any documentation about how to work with all available functions and properties regarding fields and text - not just to have to look through the dictionary to find out and do a lot of trial and error?
This would also include the visual properties such as margins, lineheight etc. There is something, but I do not fully understand all the possibilities yet.
Then maybe someone has already done this?
Another way I was thinking - but I am not sure about it. If I forget about any tables and lists (not speaking of the datagrid anyway), would it make sense using individual feels which are put together as rows, and each row could be a group for example.
Then I can clone the row group and add it to the bottom of the previous row. Or i can create a number of rows which then look like a spreadsheet and have people enter into these pseudo cells. And users can add more such rows as they like.
The advantage would be that cells are actually fields, and it is probably easier to manage everything.
What I did was some tests: Each field has a cell name such as "F_1_1", "F_1_2" etc. So the first item indicates the position in a row, the second item the position of the column. Then I can use variables. Let us say, I have a variable tRow, and a variable tCol. It does not work using "F_" & tRow &"_"& tCol directly addressing such one field. But if I put it the following way:
Code snippet:
put "F_" &tRow& "_" &tCol into fName
put "Hello" into field fName
This works really nicely.
And I can change the properties such as alignment, color, width, etc.
So, using a repeat loop, I can change the size of one column with all fields of that column and even make it be another column, swapping columns, creating new ones, deleting columns, inserting them, reformatting them, etc.
-- tRow = number of rows
-- tCol = number of columns
repeat with i = 1 to tRow
repeat with j = 1 to tCol
put "F_" & tRow & "_" & tCol into fName
-- do something with field f Name
end repeat
end repeat
Well, I imagine this leads to quite many functions, especially if this should work based on what the user is doing with each action recalculating everything.
For some rows and columns this might be fine, but what about data with 100, or 1,000 or 10,000 rows? I think then it will become too slow.
Maybe I am thinking in the wrong direction? I would like to be corrected here if this is the case.
I looked at the Datagrid, but I can not see (yet) how to customize it to have such functionality as I would like to have. And it uses arrays which I do not master yet in LC. But maybe I should consider them rather than possibly reinventing the wheel? Datagrid is a bit confusing to me. And I imagine I must spend at least a weekend to understand parts of it.
Any direction is HIGHLY welcome, please...