+1-888-365-2779
Try Now
More in this section

Forums / Sitefinity SDK / Equivlant of CreateHostViewCommand("SomeViewView", itemId.ToString(), Nothing)

Equivlant of CreateHostViewCommand("SomeViewView", itemId.ToString(), Nothing)

4 posts, 0 answered
  1. TIOS
    TIOS avatar
    48 posts
    Registered:
    22 Mar 2006
    17 Dec 2010
    Link to this post
    Hi,

    Stuggling to find this as the jobs sample doesnt show me, i've effectively created a few control views now (just SimpleView's for now) AuctionsOverview needs to somethingelse.ascx in the views folder via a hyperlink from the first control.

    How do you do this?

    In Sitefinity 3.7 I hooked onto the ItemDataBound event and set the hyperlink of a custom item template on the fly using CreateHostViewCommand("SomeViewView", itemId.ToString(), Nothing).

    Thanks,
    Chris
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    17 Dec 2010
    Link to this post
    Hello Chris,

    In 4.0 we use definition classes and the architecure is completely diferent from what you see in 3.x.

    In the definition you have

    1. ListView - it is represented by MasterGridViewElement

     
    var moduleGridView = new MasterGridViewElement(backendContentView.ViewsConfig)
              {
                  ViewName = ModuleDefinitions.BackendListViewName,
                  ViewType = typeof(MasterGridView),
                  AllowPaging = true,
                  DisplayMode = FieldDisplayMode.Read,
                  ItemsPerPage = 50,
                  ResourceClassId = typeof(ModuleResources).Name,
                  ExtendedSearchFields = "Title",
                  SortExpression = "Title ASC",
                  Title = "Title",
                  WebServiceBaseUrl = "~/Sitefinity/Services/Content/ContentItemService.svc/"
              }


    This view is populated by a web service that you should create to bind the items.

    2. Then you have a mode of the grid where you populate the client data like - status, author, title etc

          
    var gridMode = new GridViewModeElement(moduleGridView .ViewModesConfig)
           {
               Name = "Grid"
           };
           (moduleGridView .ViewModesConfig.Add(gridMode);
     
           DataColumnElement titleColumn = new DataColumnElement(gridMode.ColumnsConfig)
           {
               Name = "Title",
               HeaderText = Res.Get<Labels>().Title,
               HeaderCssClass = "sfTitleCol",
               ItemCssClass = "sfTitleCol",
               ClientTemplate = @"<a sys:href='javascript:void(0);' sys:{{ 'sf_binderCommand_edit sfItemTitle sf' + UIStatus.toLowerCase()}}"">
                   <strong>{{Title}}</strong>
                   <span class='sfStatusLocation'>{{Status}}</span></a>"
           };
           gridMode.ColumnsConfig.Add(titleColumn);
     
           var translationsColumn = new DynamicColumnElement(gridMode.ColumnsConfig)
           {
               Name = "Translations",
               HeaderText = Res.Get<LocalizationResources>().Translations,
               DynamicMarkupGenerator = typeof(LanguagesColumnMarkupGenerator),
               ItemCssClass = "sfLanguagesCol",
               HeaderCssClass = "sfLanguagesCol"
           };
           translationsColumn.GeneratorSettingsElement = new LanguagesColumnMarkupGeneratorElement(translationsColumn)
           {
               LanguageSource = LanguageSource.Frontend,
               ItemsInGroupCount = DefinitionsHelper.LanguageItemsPerRow,
               ContainerTag = "div",
               GroupTag = "div",
               ItemTag = "div",
               ContainerClass = string.Empty,
               GroupClass = string.Empty,
               ItemClass = string.Empty
           };
           gridMode.ColumnsConfig.Add(translationsColumn);
     
           ActionMenuColumnElement actionsColumn = new ActionMenuColumnElement(gridMode.ColumnsConfig)
           {
               Name = "Actions",
               HeaderText = Res.Get<Labels>().Actions,
               HeaderCssClass = "sfMoreActions",
               ItemCssClass = "sfMoreActions"
           };
           DefinitionsHelper.FillActionMenuItems(actionsColumn.MenuItems, actionsColumn, typeof(NewsResources).Name);
           gridMode.ColumnsConfig.Add(actionsColumn);
     
           DataColumnElement authorColumn = new DataColumnElement(gridMode.ColumnsConfig)
           {
               Name = "Author",
               HeaderText = Res.Get<Labels>().Author,
               ClientTemplate = "<span>{{Author}}</span>",
               HeaderCssClass = "sfRegular",
               ItemCssClass = "sfRegular"
           };
           gridMode.ColumnsConfig.Add(authorColumn);
     
           DataColumnElement dateColumn = new DataColumnElement(gridMode.ColumnsConfig)
           {
               ///.format('dd MMM, yyyy hh:mm:ss')
               Name = "Date",
               HeaderText = Res.Get<Labels>().Date,
               ClientTemplate = "<span>{{ (DateCreated) ? DateCreated.sitefinityLocaleFormat('dd MMM, yyyy hh:mm:ss'): '-' }}</span>",
               HeaderCssClass = "sfDate",
               ItemCssClass = "sfDate"
           };
           gridMode.ColumnsConfig.Add(dateColumn);


    3. You should have decision screen - create item, edit item


    DecisionScreenElement dsElement = new DecisionScreenElement((moduleGridView .DecisionScreensConfig)
     {
         Name = "NoItemsExistScreen",
         DecisionType = DecisionType.NoItemsExist,
         MessageType = MessageType.Neutral,
         Displayed = false,
         Title = "WhatDoYouWantToDoNow",
         MessageText = "NoItems",
         ResourceClassId = typeof((moduleResources).Name
     };
     
     CommandWidgetElement actionCreateNew = new CommandWidgetElement(dsElement.Actions)
     {
         Name = "Create",
         ButtonType = CommandButtonType.Create,
         CommandName = DefinitionsHelper.CreateCommandName,
         Text = "CreateItem",
         ResourceClassId = typeof(moduleResources).Name,
         CssClass = "sfCreateItem",
         PermissionSet = SecurityConstants.Sets.General.SetName,
         ActionName = SecurityConstants.Sets.General.Create
     };
     dsElement.Actions.Add(actionCreateNew);
     
     
    moduleGridView.DecisionScreensConfig.Add(dsElement);

    4. You need edit/insert form view

     
    var  EditDetailView = new DetailFormViewElement(backendContentView.ViewsConfig)
                {
                    Title = "EditItem",
                    ViewName = ModuleDefinitions.BackendEditViewName,
                    ViewType = typeof(DetailFormView),
                    ShowSections = true,
                    DisplayMode = FieldDisplayMode.Write,
                    ShowTopToolbar = true,
                    ResourceClassId = typeof(NewsResources).Name,
                    WebServiceBaseUrl = "~/Sitefinity/Services/Content/ContentItemService.svc/",
                    IsToRenderTranslationView = true,
                    AlternativeTitle = "CreateNewItem"
                };
     
                backendContentView.ViewsConfig.Add(EditDetailView );
     
             var InsertDetailView = new DetailFormViewElement(backendContentView.ViewsConfig)
                {
                    Title = "CreateNewItem",
                    ViewName = ModuleDefinitions.BackendInsertViewName,
                    ViewType = typeof(DetailFormView),
                    ShowSections = true,
                    DisplayMode = FieldDisplayMode.Write,
                    ShowTopToolbar = true,
                    ResourceClassId = typeof(moduleResources).Name,
                    WebServiceBaseUrl = "~/Sitefinity/Services/Content/ContentItemService.svc/",
                    IsToRenderTranslationView = false
                };
     
                backendContentView.ViewsConfig.Add(InsertDetailView);

    Most of the things above are just a configuration, as you can see there is no coding. We will have a sample module and documentation for it shortly so you will be able to get the idea.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. TIOS
    TIOS avatar
    48 posts
    Registered:
    22 Mar 2006
    17 Dec 2010
    Link to this post
    Ok thanks - i'm stuggling to get my head around that and how that fits in with the jobs module sample, think i might wait until the sample is released to ensure I dont waste too much time rewriting code.

    Do you have to use a web service for that data, what about calling a stored procedure? The procedure in question looks something like SELECT Auctions.*, Departments.Name AS DepartmentName, Departments.AuctionType, Departments.[Role] FROM Auctions INNER JOIN Departments ON Auctions.DeptID = Departments.DeptID WHERE Departments.[Role] IN ('role1','role2','etc') nothing special but because of the IN statement not looked at converting it to fluet api, then it would a case of putting that into a web service wrapper.

    Bear in mind i'm not using your dynamic database tables but my own inside the sitefinity database as I have other windows forms apps, etc hooked onto it.

    Also say for example you had a listview that needed an import button at the top of the page that went to a seperate view that does an excel import.  With the old api it was relatively easy to write a hook and navigate to it...

    Thanks,
    Chris
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    17 Dec 2010
    Link to this post
    Hi Chris,

    We use RESTful services and client side binders. The data is persisted by Telerik Open Access which is responsible for database management.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
4 posts, 0 answered