Some Ribbon Templates

Mar 7, 2012 at 8:29 PM

Some Ribbon Templates I have created. You can properly include in your release.

     public static GroupTemplateDefinition TwoLargeTwoRowsFourMedium()
        {
            var template = new GroupTemplateDefinition()
            {
                Id = "TwoLargeTwoRowsFourMedium",
                SizeId = "Large",
                SectionIds = new string[] { "c1", "c2", "c3", "c4", "c5", "c6" },
                GetXMLFunc = (GroupTemplateDefinition definition) =>
                {
                    return
                @"<GroupTemplate Id=""" + definition.Id + @""">
	                            <Layout Title=""Large"">
		                            <Section Type=""OneRow"">
			                            <Row>
				                            <ControlRef TemplateAlias=""c1"" DisplayMode=""Large"" />
			                            </Row>
		                            </Section>
		                            <Section Type=""OneRow"">
			                            <Row>
				                            <ControlRef TemplateAlias=""c2"" DisplayMode=""Large"" />
			                            </Row>
		                            </Section>
		                            <Section Type=""TwoRow"">
			                            <Row>
				                            <ControlRef TemplateAlias=""c3"" DisplayMode=""Medium"" />
			                            </Row>
			                            <Row>
				                            <ControlRef TemplateAlias=""c4"" DisplayMode=""Medium"" />
			                            </Row>
		                            </Section>
		                            <Section Type=""TwoRow"">
			                            <Row>
				                            <ControlRef TemplateAlias=""c5"" DisplayMode=""Medium"" />
			                            </Row>
			                            <Row>
				                            <ControlRef TemplateAlias=""c6"" DisplayMode=""Medium"" />
			                            </Row>
		                            </Section>
	                            </Layout>
                            </GroupTemplate>";
                }
            };

            return template;
        }


        public static GroupTemplateDefinition TwoRowsFourMediumOneLarge()
        {
            var template =  new GroupTemplateDefinition()
                    {
                        Id = "TwoRowsFourMediumOneLarge",
                        SizeId = "Large",
                        SectionIds = new string[] { "c1", "c2", "c3", "c4", "c5" },
                        GetXMLFunc = (GroupTemplateDefinition definition) =>
                        {
                            return
                        @"<GroupTemplate Id=""" + definition.Id + @""">
	                            <Layout Title=""Large"">
		                            <Section Type=""TwoRow"">
			                            <Row>
				                            <ControlRef TemplateAlias=""c1"" DisplayMode=""Medium"" />
			                            </Row>
			                            <Row>
				                            <ControlRef TemplateAlias=""c2"" DisplayMode=""Medium"" />
			                            </Row>
		                            </Section>
		                            <Section Type=""TwoRow"">
			                            <Row>
				                            <ControlRef TemplateAlias=""c3"" DisplayMode=""Medium"" />
			                            </Row>
			                            <Row>
				                            <ControlRef TemplateAlias=""c4"" DisplayMode=""Medium"" />
			                            </Row>
		                            </Section>
		                            <Section Type=""OneRow"">
			                            <Row>
				                            <ControlRef TemplateAlias=""c5"" DisplayMode=""Large"" />
			                            </Row>
		                            </Section>
	                            </Layout>
                            </GroupTemplate>";
                        }
                    };

            return template;
        }


        public static GroupTemplateDefinition TwoLargeTwoMedium()
        {
            var template = new GroupTemplateDefinition()
          {
              Id = "TwoLargeTwoMedium",
              SizeId = "Large",
              SectionIds = new string[] { "c1", "c2", "c3", "c4" },
              GetXMLFunc = (GroupTemplateDefinition definition) =>
              {
                  return
              @"<GroupTemplate Id=""" + definition.Id + @""">
	                <Layout Title=""Large"">
		                <Section Type=""OneRow"">
			                <Row>
				                <ControlRef TemplateAlias=""c1"" DisplayMode=""Large"" />
			                </Row>
		                </Section>
		                <Section Type=""OneRow"">
			                <Row>
				                <ControlRef TemplateAlias=""c2"" DisplayMode=""Large"" />
			                </Row>
		                </Section>
                        <Section Type=""TwoRow"">
			                <Row>
				                <ControlRef TemplateAlias=""c3"" DisplayMode=""Medium"" />
			                </Row>
			                <Row>
				                <ControlRef TemplateAlias=""c4"" DisplayMode=""Medium"" />
			                </Row>
		                </Section>
	                </Layout>
                </GroupTemplate>";
              }
          };

            return template;
        }

        public static GroupTemplateDefinition ThreeLargeTwoMedium()
        {
            var template = new GroupTemplateDefinition()
            {
                Id = "ThreeLargeTwoMedium",
                SizeId = "Large",
                SectionIds = new string[] { "c1", "c2", "c3", "c4", "c5" },
                GetXMLFunc = (GroupTemplateDefinition definition) =>
                {
                    return
                @"<GroupTemplate Id=""" + definition.Id + @""">
	                <Layout Title=""Large"">
		                <Section Type=""OneRow"">
			                <Row>
				                <ControlRef TemplateAlias=""c1"" DisplayMode=""Large"" />
			                </Row>
		                </Section>
		                <Section Type=""OneRow"">
			                <Row>
				                <ControlRef TemplateAlias=""c2"" DisplayMode=""Large"" />
			                </Row>
		                </Section>
		                <Section Type=""OneRow"">
			                <Row>
				                <ControlRef TemplateAlias=""c3"" DisplayMode=""Large"" />
			                </Row>
		                </Section>
                        <Section Type=""TwoRow"">
			                <Row>
				                <ControlRef TemplateAlias=""c4"" DisplayMode=""Medium"" />
			                </Row>
			                <Row>
				                <ControlRef TemplateAlias=""c5"" DisplayMode=""Medium"" />
			                </Row>
		                </Section>
                    </Layout>
                </GroupTemplate>";
                }
            };

            return template;
        }

        public static GroupTemplateDefinition OneLargeThreeMedium()
        {

            var template = new GroupTemplateDefinition()
           {
               Id = "OneLargeThreeMedium",
               SizeId = "Large",
               SectionIds = new string[] { "c1", "c2", "c3", "c4" },
               GetXMLFunc = (GroupTemplateDefinition definition) =>
               {
                   return 
                        @"<GroupTemplate Id=""" + definition.Id + @""">
                                <Layout Title=""Large"">
                                      <Section Type=""OneRow"">
                                            <Row>
                                              <ControlRef TemplateAlias=""c1"" DisplayMode=""Large"" />
                                            </Row>
                                      </Section>
                                     <Section Type=""ThreeRow"">
                                        <Row>
                                            <ControlRef TemplateAlias=""c2"" DisplayMode=""Medium"" />
                                        </Row>
                                        <Row>
                                          <ControlRef TemplateAlias=""c3"" DisplayMode=""Medium"" />
                                        </Row>
                                        <Row>
                                          <ControlRef TemplateAlias=""c4"" DisplayMode=""Medium"" />
                                        </Row>
                                  </Section>
                                </Layout>
                              </GroupTemplate>";

               }
           };

            return template;
        }

        public static GroupTemplateDefinition TwoLargeThreeMedium()
        {

            var template = new GroupTemplateDefinition()
            {
                Id = "TwoLargeThreeMedium",
                SizeId = "Large",
                SectionIds = new string[] { "c1", "c2", "c3", "c4" , "c5"},
                GetXMLFunc = (GroupTemplateDefinition definition) =>
                {
                    return
                         @"<GroupTemplate Id=""" + definition.Id + @""">
                                <Layout Title=""Large"">
                                      <Section Type=""OneRow"">
                                            <Row>
                                              <ControlRef TemplateAlias=""c1"" DisplayMode=""Large"" />
                                            </Row>
                                      </Section>
                                      <Section Type=""OneRow"">
                                            <Row>
                                              <ControlRef TemplateAlias=""c2"" DisplayMode=""Large"" />
                                            </Row>
                                      </Section>
                                     <Section Type=""ThreeRow"">
                                        <Row>
                                            <ControlRef TemplateAlias=""c3"" DisplayMode=""Medium"" />
                                        </Row>
                                        <Row>
                                          <ControlRef TemplateAlias=""c4"" DisplayMode=""Medium"" />
                                        </Row>
                                        <Row>
                                          <ControlRef TemplateAlias=""c5"" DisplayMode=""Medium"" />
                                        </Row>
                                  </Section>
                                </Layout>
                              </GroupTemplate>";

                }
            };

            return template;
        }

        public static GroupTemplateDefinition TwoLargeThreeMediumTwoLarge()
        {

            var template = new GroupTemplateDefinition()
            {
                Id = "TwoLargeThreeMediumTwoLarge",
                SizeId = "Large",
                SectionIds = new string[] { "c1", "c2", "c3", "c4", "c5", "c6", "c7" },
                GetXMLFunc = (GroupTemplateDefinition definition) =>
                {
                    return
                         @"<GroupTemplate Id=""" + definition.Id + @""">
                                <Layout Title=""Large"">
                                      <Section Type=""OneRow"">
                                            <Row>
                                              <ControlRef TemplateAlias=""c1"" DisplayMode=""Large"" />
                                            </Row>
                                      </Section>
                                      <Section Type=""OneRow"">
                                            <Row>
                                              <ControlRef TemplateAlias=""c2"" DisplayMode=""Large"" />
                                            </Row>
                                      </Section>
                                     <Section Type=""ThreeRow"">
                                        <Row>
                                            <ControlRef TemplateAlias=""c3"" DisplayMode=""Medium"" />
                                        </Row>
                                        <Row>
                                          <ControlRef TemplateAlias=""c4"" DisplayMode=""Medium"" />
                                        </Row>
                                        <Row>
                                          <ControlRef TemplateAlias=""c5"" DisplayMode=""Medium"" />
                                        </Row>
                                  </Section>
                                      <Section Type=""OneRow"">
                                            <Row>
                                              <ControlRef TemplateAlias=""c6"" DisplayMode=""Large"" />
                                            </Row>
                                      </Section>
                                      <Section Type=""OneRow"">
                                            <Row>
                                              <ControlRef TemplateAlias=""c7"" DisplayMode=""Large"" />
                                            </Row>
                                      </Section>
                                </Layout>
                              </GroupTemplate>";

                }
            };

            return template;
        }

        public static GroupTemplateDefinition OneLargeTwoMedium()
        {

            var template = new GroupTemplateDefinition()
            {
                Id = "OneLargeTwoMedium",
                SizeId = "Large",
                SectionIds = new string[] { "c1", "c2", "c3" },
                GetXMLFunc = (GroupTemplateDefinition definition) =>
                {
                    return
                         @"<GroupTemplate Id=""" + definition.Id + @""">
                                <Layout Title=""Large"">
                                      <Section Type=""OneRow"">
                                            <Row>
                                              <ControlRef TemplateAlias=""c1"" DisplayMode=""Large"" />
                                            </Row>
                                      </Section>
                                     <Section Type=""TwoRow"">
                                        <Row>
                                            <ControlRef TemplateAlias=""c2"" DisplayMode=""Medium"" />
                                        </Row>
                                        <Row>
                                          <ControlRef TemplateAlias=""c3"" DisplayMode=""Medium"" />
                                        </Row>
                                  </Section>
                                </Layout>
                              </GroupTemplate>";

                }
            };

            return template;
        }

Coordinator
Mar 9, 2012 at 8:36 AM

warfee, thanks a million! :)

Jul 20, 2012 at 5:47 AM
Edited Jul 20, 2012 at 5:49 AM

Hi, warfee,

Thank you share this template code.

public class CustomGroupTemplateDefinition    {       

	public static GroupTemplateDefinition TwoLargeTwoRowsFourMedium(){ ... }

	...

}
public override Definitions.TabDefinition GetTabDefinition()
        {
            return new TabDefinition()
            {
                Id = "CommonTasks",
                Title = "Common tasks",
                Groups = new GroupDefinition[]
            {
                new GroupDefinition()
                {
                    Id = "Sample",
                    Title = "Sample",
                    Template = CustomGroupTemplateDefinition.TwoLargeTwoMedium(),
                    //Template=GroupTemplateLibrary.SimpleTemplate,
                    Controls = new ControlDefinition[]
                    {
                        ... //Some code 
                    }
               }
 
            }
        }

and I deploy and run this , I get page script error:

“A template with name:TwoLargeTwoRowsFourMedium could not be loaded.

scriptResource.axd line five

 

Thanks.

Feb 14, 2013 at 1:45 PM
Edited Feb 14, 2013 at 1:52 PM
Hi.

I think you need to add something like...
 public static GroupTemplateDefinition[] AllTemplates
        {
            get
            {
                return new GroupTemplateDefinition[]
                {
                    SimpleTemplate,
                    ThreeRowTemplate,
                    ##YourTemplateName##           
              };
            }
        }
And change a little header:
public static GroupTemplateDefinition OneLargeTwoMedium = new GroupTemplateDefinition()
        {
            
                Id = "OneLargeTwoMedium",
                SizeId = "Large",

     SectionIds = new string[] { "c1", "c2", "c3" },..............