Displays data in a grid.
The user can edit cells whose column's field information is configured as editable in grid.
Editing is performed on a cell-basis and the procedure is called to save changes before another cell can start editing.
The excel export button is in the upper right corner. It is shown by default, but can be hidden by grid settings. It is not shown on small screen devices.
Row links are clickable icons that are displayed on each row. If there are more rowlinks than the maximum available space (adjustable by a setting), the ...-button is displayed which gives access to the rest of the rowlinks. If a row link is not relevant on every row, you can hide it on a per-row basis.
You can choose to display a column of checkboxes. These allow for operations on multiple rows at once. In this example, the top button "Set tax status" is used to set the tax status of the cars that the user has checked.
To sort by a column, you click it's heading. To reverse the order you click it again.
The user can choose one column to group by. The column will then be removed from the grid, and it's values will instead appear as headings. In this example the "Fuel" column has been choosen. You can specify a default grouping in the grid settings.
The total number of rows is always shown (384 in this example). If it's too many to display at once, the grid will divide the results into pages. The default page size is 50 rows, but it can be customized. In this example the page size has been set to six rows. Hence the total number of pages is 384/6 = 64.
To navigate, there are clickable arrows for previous/next page, and a textbox where you can type an arbitrary page number (after the word "Page" in the screenshot). You can also use the PgUp/PgDown keys move to previous/next page, and Home/End for the first/last page.
You can choose to display a sum below any numerical column, which will be automatically computed by the platform. If you need other forms of aggregation (other than simple addition) you can provide the aggregate values manually.
You can set the color for specific rows and cells. In this example the cells in the Brand column are given different colors for different brands, while the whole row is grayed out for cars with status = Sold. In addition to color you can set arbitrary css-style attributes for whole rows as well as individual cells. Using these attributes you can make quite remarkable changes to the grids appearance. Artistic restraint is advised.
You can set the tooltip text for individual cells, row links and columns headings. In this example the user gets additional information about the model by hoovering the mouse over the Model cell.
You can provide extra text about a row in the grid, that shows up on demand. Existence of extra text is indicated by a down-arrow that appears in it's own column.
When you click the arrow, the text appears inserted below the corresponding row like this:
The extra text can include html formatting if needed.
The columns of a grid can be assigned column groups. This can save horizontal space (in this example, the words "Owner" and "Previous owner" don't have to be repeated for each column).
You can use the grid setting Show checkboxes to enable checkboxes on a menu item.
The grid menu item can pass the ids of its selected rows, for historical reasons commonly referred to as selecteditems via links from the grid to other menu items. These menu items then access these ids as a comma-separated string.
Checkboxes use the values from the first grid column as row ids. Row ids must be unique unless they are NULL. Any row with NULL in the first column will not show a checkbox.
The row ids that you access through selecteditems are ID values of rows that were valid when the user loaded the grid. No validation is performed to ensure that the ID values are still valid, that their rows would still be visible if the user reloads the grid.
For example, you have a grid of unsent invoices and a top-link "Send all checked invoices". The user checks a few rows and then clicks the top link. Now, the checked invoices are sent, and their rows will no longer appear in the grid, but the grid still remembers the IDs of the checked rows. If the user checks a few more rows and clicks the top link again then the Send-menuitem will receive both the IDs of the invoices already sent and the new IDs. You can avoid this by using the execute component's special column admin_unselectall
to clear all checkboxes.
Possible value | Description |
---|---|
xlsx | The document is generated as a Microsoft Excel 2007 (*.xlsx) document. InfoSql and style information will be rendered. |
text | The document is generated as tab separated text. InfoSql and style information will not be rendered. This mode causes a warning when opened in Microsoft Excel 2007 and later versions. |
Call made to retrieve the data to display in the grid.
The content to be shown in a grid column. The formatting of the value is determined by the connected field information. If the the field information has Allow HTML enabled in its Display Settings, the value will be treated as HTML of the Safe HTML level.
In case the field information is of type Hidden, the column will be excluded from the grid. This feature is useful for columns intended solely to provide values for use by links.
Specifies a custom row title for the list grid (that is, the mobile grid). If you do not specify at least one of Row_ListViewTitle, Row_ListViewText or Row_ListViewHtml then the first visible column will become the row title.
Specifies the body for a custom row description for the list grid (that is, the mobile grid). Usually used together with Row_ListViewTitle. Mutually exclusive with Row_ListViewHtml.
Specifies the body for a custom row description for the list grid (that is, the mobile grid). Can be used together with Row_ListViewTitle or by iteslf. Mutually exclusive with Row_ListViewText.
Sets the text color of <colname> to the specified color. See Colors.
Color to use for the icon specified in <colname>_Icon. See Colors.
Can be used to prevent editing of a grid cell in a column that would normally be editable. Use the Row_IsEditable column instead if you want to disable all cells on the row.
"Editable" must be set for the the field info, otherwise this column has no effect.
Sets the text color of the entire row. See Colors.
Text used to identify the row for screen readers. Row_ListViewTitle will be used as a fallback if this is not set.
If set to 1 the row's ExtraText/ExtraHtml will start expanded.
The alignment of grid columns and InfoSQL values.
Possible value | Description |
---|---|
center | Only applicable to grid columns. |
left | |
right |
Extended description for the field.
Possible value | Description |
---|---|
boolean checkbox | Legacy alias. Use "checkbox" instead. |
boolean dropdown | |
chart | |
checkbox | |
checkbox tree | |
colorpicker | |
date | |
datetime | |
dropdown | |
file | |
file upload area | |
heading | |
heading with checkbox | |
hidden | |
html | Legacy alias. Use "html editor" instead. |
html editor | |
info text | |
listbox | |
multi-autosearch | |
multi-listbox | |
multi-picker | |
multirow | |
password | |
picture | |
radio buttons | |
radio cards | |
signature | |
textarea | |
textbox | |
textbox with autosearch | |
textbox with autosuggest | |
textbox with dropdown | |
textbox with popup | |
time | |
uneditable text |
Possible value | Description |
---|---|
Default | Inherit layout from menu item. |
LabelAbove | Full width, label above. |
LabelLeft | Label to the left. |
NoLabel | Full width, no label. |
Standard | Deprecated. Use LabelLeft instead. |
JavaScript that controls the mandatory status of the field, this overwrites nullchoice if set. This is only available to control types for which the mandatory JavaScript field is visible in the user interface.
Possible value | Description |
---|---|
Hyperlink | |
MailToLink | |
PhoneLink |
Which direction the script is written in. Not to be confused with the CellAlignment property.
Possible value | Description |
---|---|
default | System default. Not useful unless you are trying to override an already explicit text direction on existing field information. |
ltr | Left-to-right (for example English) |
rtl | Right-to-left (for example Arabic) |
The width of the control.
At one point, this was a pixel value. Back when Softadmin used Verdana 10px, and before fields had width-categories. Now, it is just a value that is converted to a width category.
The possible values listed below are just suggestions. For example, both 1 and 30 will be converted to shortest, and both 500 and 9999 to longest.
Possible value | Description |
---|---|
150 | Medium-long |
30 | Shortest |
300 | Long |
500 | Longest |
60 | Short |
90 | Medium short |
The component makes this call just before saving changes to verify that the data in the row that the user is editing has not already been changed by another user.
A temp table #Row will be passed to the procedure, containing a single row with the values of the grid-row currently edited.
Decimal and numeric fields in the temporary table #Row will get their precision from the actual values during insert/update.
The user has edited a cell, and the grid should now either save the changes and return an updated row or reject the changes.
If the grid uses dynamic field information then the same dynamic fields should be returned from this call as from the original.
A temp table #Row will be passed to the procedure, containing a single row with the new values of the grid-row.
Decimal and numeric fields in the temporary table #Row will get their precision from the actual values during insert/update.
Displays a user friendly error message to the user.
The dialog alias of a predefined dialog to show the user. Must be the first column in the result set table.
Use the menu item "Admin > Dialogs" to register new dialogs or find aliases for existing ones.
Allows you to validate the SQL parameters before any other SQL is run in the component. This call is only made if the SQL is a stored procedure and Validate parameters is checked.
Use this call to restrict which entries a user is allowed to view and edit, and to log which entries a user views.
Access to a menu item is normally controlled through functions and roles alone but some entities need more fine grained control. For example, a user may have access to the View Member menu item for normal members but not for members with a protected identity.
The menu items a user visits are always logged (in ADMINLogMenuItem) but for sensitive data you may need to log exactly what entries are viewed. Do the logging in this call as the common ways of viewing data (grid and InfoSQL) are not allowed to modify the database.
If you bind a scalar function instead of a stored procedure to this call then its name must end with '_GrantAccess'.
This editable grid uses the _DisplayValue-column to support its two dropdown columns, StatusId
and UserIdAssignedTo
.
CREATE OR ALTER PROCEDURE ToDo.Task_EditableGrid
@Action varchar(100) = NULL,
@ColumnName sysname = NULL
AS
BEGIN
DECLARE @TaskId int;
IF @Action = 'SaveCell'
BEGIN
-- Validate
IF (SELECT R.Status FROM #Row R) <= 0
BEGIN
SELECT 'Illegal Status' [ADMIN_Message];
RETURN;
END
-- Update all editable columns instead of switching on @ColumnName parameter.
UPDATE ToDo.Task SET
StatusId = R.StatusId,
UserIdAssignedTo = R.UserIdAssignedTo,
Task = R.Task,
@TaskId = T.TaskId -- Fetch the primary key so we can return the correct row as response.
FROM
ToDo.Task T
JOIN #Row R ON R.TaskId = T.TaskId;
END;
IF @Action = 'GetRow'
BEGIN
SELECT @TaskId = (SELECT TaskId FROM #Row);
END;
SELECT
T.TaskId,
T.Task,
S.StatusId,
S.Status AS StatusId_DisplayValue, -- Edit status as ID but show it as text.
S.SortOrder AS StatusId_SortOrder, -- Sort status based on its internal sortorder instead of by alphabet.
T.UserIdAssignedTo,
U.FirstNameLastName AS UserIdAssignedTo_DisplayValue
FROM
ToDo.Task T
JOIN ToDo.Status S ON S.StatusID = T.StatusId
LEFT JOIN SoftadminApi.[User] U ON U.UserId = T.UserIdAssignedTo
WHERE
(@TaskId IS NULL OR T.TaskId = @TaskId) -- Return all rows for normal call. Return single row for SaveCell and GetRow actions.
END
Name your Editable grid stored procedure with suffix _SearchEdit
or _EditableGrid
.
Editable grid is an extension of grid, not a replacement for multirow controls in a newEdit.
If you want to convert existing multirows to editable grid then you have to rewrite much from scratch.
Editable grid can handle validation with ADMIM_Message and ADMIN_Force, but if you have a lot of dependencies it's probably not suitable to build an editable grid. It's a risk that you end up with duplicated code in both the Editable Grid and the InsertUpdate procedures. Also, you must save the row to the data base after you edit each cell, not all cells on the whole row at the same time. You are free to actually update anything on the save though.
Note that if you want to signal ADMIN_Message, ADMIN_Force or ReloadGrid, then you should only return that table, not the row that was edited. (With force and message, there is nothing to update and nothing new to show, and with ReloadGrid, you will get the new row with the rest of the reloaded data.)