K10 Custom modules, unigrid, and more

Keith Donnell asked on January 4, 2017 18:33

I am trying to develop a custom module using Kentico best practices where possible. I have been following the article at https://docs.kentico.com/k10/custom-development/creating-custom-modules, however I have found little direction when it comes to the following:

1 - When dealing with a custom UniGrid, I have had no luck passing a parameter with the EditActionUrl. From my understanding, the first column declared in the Columns property should be the 0-indexed string format parameter, however my EditActionUrl of "~/CMSModules/VendorOrders/EditVendorOrder.aspx?VendorID={0}" always takes the '{0}' as a literal. The only way I have gotten this to work is to create a custom OnAction handler with a Response.Redirect() to the appropriate editor page, but this doesn't feel best practice to me. Here is my relevant source:

ASPX:

<cms:UniGrid ID="gridCurrentOrders" runat="server" OrderBy="Name" 
    Columns="VendorID,Name,ItemCount,TotalQuantity,TotalCost"
    EditActionUrl="~/CMSModules/VendorOrders/EditVendorOrder.aspx?VendorID={0}">
    <GridActions Width="50">
        <ug:Action Name="edit" Caption="$General.Edit$" FontIconClass="icon-edit" FontIconStyle="allow" />
    </GridActions>
    <GridColumns>
        <ug:Column source="Name" caption="Vendor" width="50"></ug:Column>
        <ug:Column source="ItemCount" caption="Item Count" width="25"></ug:Column>
        <ug:Column source="TotalQuantity" caption="Total Qty" width="25"></ug:Column>
        <ug:Column source="TotalCost" caption="Item Cost" width="100%"></ug:Column>
    </GridColumns>
</cms:UniGrid>

Code Behind:

protected void Page_Load(object sender, EventArgs e)
{
    // Calculate which SKUs need to be reordered as follows:
    // When [AvailableItems] + [Amount unshipped already on an open vendor order] is at or less than [ReorderAt], reorder [ReorderQuantity]
    gridCurrentOrders.DataSource = SKUInfoProvider.GetSKUs()
        .Source(sku => sku.Join<VendorInfo>("SKUVendorID", "VendorID"))
        .Where("SKUAvailableItems <= SKUReorderAt")
        .GroupBy("VendorID", "Name")
        .Columns("VendorID, Name, count(SKUID) as ItemCount, sum(SKUReorderQuantity) as TotalQuantity, sum(SKUVendorCost * SKUReorderQuantity) as TotalCost")
        .Result;
 }

2 - When using the built-in templates for a Custom Module UI page, you can simply check the "Display Breadcrumbs" box, however for seemingly obvious reasons, this doesn't do anything when Type = "URL". Is there a standard way to wire up breadcrumbs on custom .aspx module pages?

TIA, -Keith

Recent Answers


Brenden Kehren answered on January 4, 2017 19:02

On the UniGrid definition have you defined the 'Parameter' property? Should be something like:

<cms:UniGrid ID="gridCurrentOrders" runat="server" OrderBy="Name" 
Columns="VendorID,Name,ItemCount,TotalQuantity,TotalCost"
EditActionUrl="~/CMSModules/VendorOrders/EditVendorOrder.aspx?VendorID={0}"
Parameter="VendorID">
0 votesVote for this answer Mark as a Correct answer

Keith Donnell answered on January 4, 2017 20:02

Yes, however that generates an error "XML definition file not found", which seems to mean that that "Parameter" setting is only valid if you're using an XML definition for your UniGrid.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on January 4, 2017 22:07

Ahh you may be correct. I always use the xml file so I'd have to go back and look at the other properties for the UniGrid.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on January 4, 2017 23:28 (last edited on January 4, 2017 23:37)

Actually, I think this might be what you need:

<GridActions Parameters="VendorId">
    <ug:Action Name="edit" Caption="$General.Edit$" FontIconClass="icon-edit" FontIconStyle="allow" CommandArgument="VendorId" />
</GridActions>

Need to add the Parameters to <GridActions> and set the CommandArgument

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.