3
votes

What i Want : I would like a custom menu on my home page. I would like to display 4 images (and links) (coming from a custom link application) in a square. (like at every edge, a couple image/link) Not like a simple list (see this :

  • MyImage1.jpg MyLink1
  • MyImage2.jpg MyLink2
  • MyImage3.jpg MyLink3
  • MyImage4.jpg MyLink4 )

What i have :

So, i've made my custom link application which contains several columns like URL, notes, ImageUrl.

On my Home, i've made a WebPart of category "Report de contenu" -which should be Content Report in english, i guess- and a component "ContentSearch".

This WebPart is displayed with a custom Control template -which is a copy of Control_List.html- and a custom Item template -which is a copy of Item_Picture3Lines.html .

What is my question : In Control_List.html, in the js, we have this :

var ListRenderRenderWrapper = function(itemRenderResult, inCtx, tpl, i)
{
        var iStr = [];
        iStr.push('<li>');
        iStr.push(itemRenderResult);
        iStr.push('</li>');
    return iStr.join('');

}

This renders every item as a li, but with all its special displaying (defined in Item_Picture3Lines.html) I would like to render these items in a 2x2 table. like

<table>
   <tr>
      <td id=Myitem1>
         <!-- All my content, displayed by the item display template -->
      </td>
      <td id=Myitem2>
         <!-- All my content, displayed by the item display template -->
      </td>
   </tr>
   <tr>
      <td id=Myitem3>
         <!-- All my content, displayed by the item display template -->
      </td>
      <td id=Myitem4>
         <!-- All my content, displayed by the item display template -->
      </td>
   </tr>
</table>

I know table are ugly etc..

My question is.. How can i know the number of items that will be displyed in my control Display Template to determine whether i have to end my and open a new one?

Thanks a lot, i'm a new beginner in Sharepoint, please be kind! :)

1

1 Answers

2
votes

your items (from the control template) are here

ctx.ListData.ResultTables[0].ResultRows

the number of items that will be displayed is

ctx.ListData.ResultTables[0].ResultRows.length