Form. How to display a tree with a selection of checkboxes

Demo stand of this feature - /tst-form-treeview

Select the field type Tree with checkboxes (treeCheckboxes). 

Specify the tree in the dict procedure as a list Value, Value2 (здесь будет parentID), Text

CREATE PROCEDURE [dbo].[fm_tst-form-treeview_f1_dict]
   @username nvarchar(256),
   @itemID nvarchar(128)
AS
BEGIN
	select c.id Value,     -- id
		c.name as Text,
		isnull(c.parentID, 0) Value2  -- parentID
    from tst_categories c
END

In the getItem procedure, you must pass the currently selected checkboxes separated by commas.

CREATE PROCEDURE [dbo].[fm_tst-form-treeview_getItem]
    @itemID int,
	@username nvarchar(256)

AS
BEGIN
	select
      STUFF((SELECT ',' + cast(id as nvarchar)
      FROM tst_categories
      WHERE selected=1
      FOR XML PATH('')), 1, 1,'') f1  -- selected categories
END

In the saveItem procedure, we save the tick values (they come as selected values separated by commas).

CREATE PROCEDURE [dbo].[fm_tst-form-treeview_saveItem]
   @username nvarchar(256),
   @itemID int,
   @parameters ExtendedDictionaryParameter READONLY
AS
BEGIN

	declare @pf1 nvarchar(max)
	select @pf1 = Value2 from @parameters where [key]='f1'

    exec as_print @str = @pf1

    update tst_categories
    set selected= 0

    update tst_categories
    set selected= 1
    where id in (select Value from dbo.split(@pf1,',') where Value<>'')

    -- SELECT 1 (Result, Msg, SuccessUrl, HideFormAfterSubmit, RefreshContainer)
	select 1 Result, 'OK' Msg, '' SuccessUrl, 0 HideFormAfterSubmit, '' RefreshContainer
END
Falcon Space is a functional web development platform on a narrow stack MS SQL/Bootstrap. Falcon Space Gettting started
{sp-shortDemostandLinks}

Falcon Space Platform

This is a reduction in the cost of ownership

at the expense of fewer people to support

This is a quick change

while using the program

This is a modern interface

full adaptation for mobile devices

Note