Does anyone have any example on how to put a date time picker inside a sharepoint project?
more specifically to put a date time picker in the gridview..
I've been googling for hours and still couldn't find example that works..
most of the example is for normal web project and not for sharepoint project..
and btw I've tried putting the datetimecontrol inside the gridview, but it doesn't work as well.
Thanks in advance.
I love to use jQuery UI's Datepicker:
http://jqueryui.com/demos/datepicker/
To implement in a GridView, I normally make an editable text box and just apply the class to it, which would invoke the datepicker:
<asp:GridView ID="gvClientDetails" runat="server">
<Columns>
<asp:TemplateField HeaderText="Date">
<EditItemTemplate>
<asp:TextBox runat="server" ID="myTextBox" CssClass="dateTextBox" />
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="myLabel" runat="server" Text='<%# Eval("myDate") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
and then make use of the below javascript (registered on your page or site wide):
$('.dateTextBox').each(function () {
$(this).datepicker(
{
changeMonth: true,
changeYear: true,
dateFormat: 'yy/mm/dd'
});
})
As for applying something like this to your sharepoint site, this should assist you:
http://blogs.lessthandot.com/index.php/WebDev/UIDevelopment/Javascript/adding-a-jquery-date-picker-to-sharepoint
Just use common standard SP DateTimeControl.
This is how we do it :
/// <summary>
/// Get common SP DateTimeControl with current DateOnly settings and MethodToProcessDateChanged
/// </summary>
public static DateTimeControl Cd(this bool DateOnly, bool AutoPostBack = false,
DateTime? SelectedDate = null, Func<bool> MethodToProcessDateChanged = null)
{
var d = new DateTimeControl();
d.DateOnly = DateOnly;
d.AutoPostBack = AutoPostBack;
if (SelectedDate != null)
d.SelectedDate = SelectedDate.Value;
if (MethodToProcessDateChanged != null)
d.DateChanged += (o, e) => { MethodToProcessDateChanged();};
return d;
}
See more details with some common usage samples here
Related
I want to display a GI on one of the tab in any screen.
For example, there is a new custom GI for OrderMargin which I want to display on SO screen on a new tab that will show the Order Margin for a particular order only.
OrderMargin is simple GI with SOOrder, SOLine and InventoryItem table joins and few columns required columns with margin calculations.
Can anyone suggest?
Let's say you've created a GI called SalesOrderMargin with 2 hidden parameters:
To embed this GI into the Sales Orders page, you should follow the steps below:
Declare new unbound field for SOOrder to return absolute URL for the SalesOrderMargin GI:
public class SOOrderExt : PXCacheExtension<SOOrder>
{
public abstract class marginGiUrl : IBqlField { }
[PXString]
[PXUIField(Visible = false)]
public string MarginGiUrl
{
get
{
if (string.IsNullOrEmpty(Base.OrderType) ||
string.IsNullOrEmpty(Base.OrderNbr)) return string.Empty;
string inqName = "SalesOrderMargin";
var url = new StringBuilder(PXGenericInqGrph.INQUIRY_URL)
.Append("?name=").Append(inqName)
.Append("&SOOrderType=").Append(Base.OrderType);
.Append("&SOOrderNbr=").Append(Base.OrderNbr);
.Append("&hidePageTitle=true");
return PX.Common.PXUrl.SiteUrlWithPath().TrimEnd('/') +
url.ToString().Remove(0, 1);
}
}
}
On the Sales Orders screen, add new tab with a PXSmartPanel container set up to render as an iframe:
<px:PXTabItem Text="Margins" >
<Template>
<px:PXSmartPanel runat="server" ID="panelMarginGI" RenderIFrame="True"
AutoSize-Enabled="true" SkinID="Frame" LoadOnDemand="true"/>
</Template>
</px:PXTabItem>
Place input control for the custom SOOrder unbound field declared in step 1 somewhere in the Sales Orders' top level PXFormView container (input control will always be hidden from the users and is only required to assign source URL for the PXSmartPanel):
<px:PXFormView ID="form" runat="server" DataSourceID="ds" Width="100%"
DataMember="Document" Caption="Order Summary"...>
<Template>
...
<px:PXTextEdit ID="edMarginGiUrl" runat="server" DataField="MarginGiUrl" />
</Template>
</px:PXFormView>
In SO301000.aspx insert JavaScript code to assign source URL for the PXSmartPanel:
<script type="text/javascript" language="javascript">
function commandResult(ds, context) {
var commands = ["ReloadPage", "Save", "Cancel", "Insert", "First", "Previous", "Next", "Last"];
if (commands.indexOf(context.command) >= 0) {
var marginGiUrl = px_alls["edMarginGiUrl"];
var smartpanel = px_alls["panelMarginGI"];
if (marginGiUrl || smartpanel) {
var url = marginGiUrl.getValue();
smartpanel.setPageUrl(url);
smartpanel.repaint();
}
}
}
</script>
Subscribe to the CommandPerformed event of PXDataSource to invoke the commandResult JavaScript function:
<px:PXDataSource ID="ds" runat="server" Visible="True" Width="100%" TypeName="PX.Objects.SO.SOOrderEntry" PrimaryView="Document">
<ClientEvents CommandPerformed="commandResult" />
...
</px:PXDataSource>
And this is how your SalesOrderMargin GI should appear on the Sales Orders screen:
I'd like to add a tab to a screen which contains a memo / formatted text area the way the Cases screen does, e.g.:
Adding a tab is straightforward, no help necessary there, but I don't remember seeing anything about how to add this type of text area in the training courses. If there's an example I'd appreciate a point in the right direction.
You can add the RichTextEditor manually to your aspx file.
<px:PXTabItem Text="Test">
<Template>
<px:PXRichTextEdit runat="server" AllowLoadTemplate="false"
AllowAttached="true" AllowSearch="true" AllowMacros="true"
AllowSourceMode="true" DataField="YOURFIELD" ID="edDescription"
Style='width:100%;'>
<AutoSize Enabled="True" />
</px:PXRichTextEdit>
</Template>
</px:PXTabItem>
Make sure you Tab has the correct Datamember where your field used on the RichTextEditor is located.
<px:PXTab DataMember="Document" ID="tab" runat="server" Height="540px" Style="z-index: 100;" Width="100%">
Also you could mark your Field used on the RichTextEditor as PXDBText.
#region YourField
public abstract class yourField : IBqlField { }
protected String _yourField;
[PXDBText(IsUnicode = true)]
[PXUIField(DisplayName = "YOURFIELD")]
public virtual String YourField
{
get
{
return this._yourField;
}
set
{
this._yourField = value;
}
}
#endregion
I have an attribute with the case number from another instance. I have to make it appear as a hyperlink so user can click on it and it can direct visit to that case.
Any suggestion.
It adds up the link to all row, but I need hyperlink only on Case Number attribute. (see below image).
Assuming you want the link inside a grid cell.
First make an action in your graph with it's primary DAC:
public PXAction<MyPrimaryDAC> viewCase;
Primary DAC can be found in the graph:
public class MyGraph : PXGraph<MyGraph, MyPrimaryDAC>
Make an event handler for the action in your graph to open the case:
[PXButton]
public virtual IEnumerable ViewCase(PXAdapter adapter)
{
// Assuming the case you want is already set as current
// Otherwise lookup case by ID if necessary
CRCase crCase = CRCases.Current as CRCase;
if (crCase != null && crCase.CaseID != null)
PXRedirectHelper.TryRedirect(this, crCase, PXRedirectHelper.WindowMode.NewWindow);
return adapter.Get();
}
Declare the action in the CallbackCommands of your ASPX page:
<asp:Content ID="cont1" ContentPlaceHolderID="phDS" runat="Server">
<px:PXDataSource ID="ds" runat="server" Visible="True" Width="100%"
PrimaryView="MyDataView" TypeName="MyNamespace.MyGraph">
<CallbackCommands>
<px:PXDSCallbackCommand CommitChanges="True" Name="ViewCase" DependOnGrid="gridCase" Visible="False" />
</CallbackCommands>
</px:PXDataSource>
</asp:Content>
Finally use LinkCommand attribute on your grid field to bind the action:
<px:PXGridColumn DataField="MyField" LinkCommand="ViewCase" />
I'm trying to build main navigation with drop down subnavigation menu anchors. I got the HTML with CSS ready, but I don't know how to do it in the sublayout and its code behind.
I have done a lot of navigations, but those were all 1-dimensional menus using asp:repeaters or asp:ListViews.
Can anyone point me to the right direction?
Essentially you will want to have nested repeaters on the number of levels (or "dimensions") you want to display on your navigation. See an example below.
<asp:Repeater runat="server" ID="TopNavRepeater" OnItemDataBound="TopNavRepeater_OnItemDataBound">
<ItemTemplate>
<sc:Link runat="server" ID="sclTopLink" Field="__Display Name" />
<asp:Repeater runat="server" ID="SecondNavRepeater" OnItemDataBound="SecondNavRepeater_OnItemDataBound">
<ItemTemplate>
<sc:Link runat="server" ID="sclSecondLink" Field="__Display Name" />
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
You will want to get the children of each Item bound to the Top Repeater and bind it to the second Repeater. Use Sitecore Link Controls to render the links to the pages by settings the Items, and Fields, on the OnItemDataBound event.
See below for a rough example
protected void Page_Load(object sender, EventArgs e)
{
TopNavRepeater.DataSource = YourHomeItem.Children();
TopNavRepeater.DataBind();
}
protected void TopNavRepeater_OnItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
var item = e.Item.DataItem as Item;
if (item == null)
return;
var sclTopLink = e.Item.FindControl("sclTopLink") as Link;
var SecondNavRepeater = e.Item.FindControl("SecondNavRepeater") as Repeater;
if (sclTopLink != null)
{
sclTopLink.Item = item;
}
if (SecondNavRepeater != null)
{
SecondNavRepeater.DataSource = item.Children;
SecondNavRepeater.DataBind();
}
}
}
i have one page and 2 user control in it and first user control have dropdownlist and second user control have another dropdown list , when we select dropdownlist of first user control than should be filled another dropdown list of second user control.... how can we achieve it ...please explaing in detain
thanks in advance...
I would expose the child DropDownList's OnSelectedItemChanged event AND the actual DropDownList at the top public level for the user control.
This would allow you to catch the OnSelectedItemChanged event in the Page and set the value of the second user control.
Let me know if you want some sample code.
Ok, so first the user control
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="SampleUserControl.ascx.cs" Inherits="WebApplication1.UserControls.SampleUserControl" %>
<asp:DropDownList runat="server" ID="DdlTest" AutoPostBack="true">
<asp:ListItem Text="Sampe 1" />
<asp:ListItem Text="Sampe 2" />
</asp:DropDownList>
now the file behind that
public partial class SampleUserControl : System.Web.UI.UserControl
{
public DropDownList InternalDropDownList
{
get { return DdlTest; }
}
protected void Page_Load(object sender, EventArgs e)
{
}
}
okay, lets go to the actual .aspx
<form id="form1" runat="server">
<div>
<uc1:SampleUserControl ID="SampleUserControl1" runat="server" />
<uc1:SampleUserControl ID="SampleUserControl2" runat="server" />
</div>
</form>
and the code behind that
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SampleUserControl1.InternalDropDownList.SelectedIndexChanged += InternalDropDownList_SelectedIndexChanged;
}
void InternalDropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
SampleUserControl2.InternalDropDownList.SelectedValue = SampleUserControl1.InternalDropDownList.SelectedValue;
}
}