Advertisement
hecrus

Tree GetItems

Oct 24th, 2020
2,631
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 2.08 KB | None | 0 0
  1. CREATE PROCEDURE [dbo].[tree_tst-catalog_getItems]
  2.     @parameters DictionaryParameter READONLY,
  3.     @username nvarchar(128 )='',
  4.     @itemID nvarchar(128)=''
  5. as
  6. begin
  7.  
  8.     declare @langID int
  9.     select @langID = try_cast(Value as int) from @parameters where [Key] = 'langID'
  10.  
  11.    
  12.     -- SELECT 1
  13.     select 1 Result, '' Msg,
  14.         1 CanRename, 1 CanAdd, 1 canDelete,
  15.         '' PlusIcon, '' MinusIcon, 0 ShowIcon, 1 ShowTags,
  16.         '0' ParentIDRootValue,
  17.         '' EmptyIcon,
  18.         '' NodeIcon
  19.    
  20.     -- SELECT 2
  21.     select c.id Id,
  22.         c.name as title,
  23.         isnull(c.parentID, 0) ParentID,
  24.         c.ord Ord,
  25.         '' Icon, -- fa fa-cube
  26.         'form' [Type],  -- // form, redirect, refreshContainer
  27.          '<a class="as-form-modal" data-code="tst-editCategory" data-itemid="'+cast(c.id as nvarchar)+'" href="#" data-btntext="'+iif(@langID=1, 'Save', 'Сохранить')+'" data-big="0" data-title="'+c.name+'" data-slideout="1"><i class="fas fa-edit"></i></a>' Value,
  28.         --'refreshContainer' [Type],
  29.         --'body' Value,
  30.         0 Expanded,
  31.         0 Selected,
  32.         'fa fa-stop' selectedIcon,
  33.         '#555' color,
  34.         '#eee' backColor,
  35.         '#' href,
  36.         1 selectable,
  37.         case when (select count(*) from tst_categoryProducts where categoryID = c.id) > 0
  38.              then '<span class="text-danger font-weight-bold">'+cast((select count(*) from tst_categoryProducts where categoryID = c.id) as nvarchar) + ' '+iif(@langID=1, 'cnt', 'тов.')+'</span>'
  39.              else '<span class="text-secondary font-weight-bold">'+cast((select count(*) from tst_categoryProducts where categoryID = c.id) as nvarchar) + ' '+iif(@langID=1, 'cnt', 'тов.')+'</span>'
  40.              end + '|' +
  41.         case when (select count(*) from tst_categories c1 where c1.parentID = c.id) > 3
  42.              then '+'+cast((select count(*) from tst_categories c1 where c1.parentID = c.id)-3 as nvarchar)+'...'
  43.              else '' end  + '|' +
  44.         isnull(STUFF((SELECT top 3 '|' +  CAST(name as nvarchar(64)) as [text()]
  45.                       FROM tst_categories c1 WHERE c1.parentID = c.id ORDER BY c1.ord
  46.                 FOR XML PATH(''), TYPE).value('.', 'VARCHAR(MAX)'), 1, 1, ''), '') AS  info
  47.     from tst_categories c
  48. end
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement