Passing Telerik Grid Data To Javascript Function Declared in 'OnClientClick'

1 Answer 102 Views
Grid Window
Ken
Top achievements
Rank 1
Ken asked on 31 Jul 2024, 07:10 PM

I am trying to open a new window when a user clicks a button but need to pass 'CallLogID' into my query parameters. For the life of me I can not seem to get the CallLogID to show up. The value of CallLogID is in a datafield set to Display="False". I have tried using <%# Eval() %> but maybe I am not using the appropriate escape characters. Any help would be much appreciated.

Here are my code snippets that are currently working to open a new tab and navigate to the specified URL.

            <telerik:GridTemplateColumn HeaderText="Follow Up" UniqueName="FollowUp">
                <HeaderStyle Width="22%" /> 
                <ItemStyle Width="22%" /> 
                <ItemTemplate>
                    <asp:LinkButton ID="lnkFollowUp" runat="server" OnClick="FollowUpView" ToolTip="Follow Up">
                        (<%# Eval("FollowUpCount") %>) view
                    </asp:LinkButton>
                    <asp:Literal ID="separator" runat="server" Text=" | " />
                    <asp:LinkButton ID="FollowUpAdd" runat="server" Text="add" ToolTip="Follow Up" OnClientClick="window.open('addfollowuptocalllog.aspx?calllogid=', '_blank'); return false;"/>
                </ItemTemplate>
            </telerik:GridTemplateColumn>

            <telerik:GridBoundColumn DataField="CallLogID" UniqueName="CallLogID" Visible="True" Display="False">
                <ColumnValidationSettings>
                    <ModelErrorMessage Text=""></ModelErrorMessage>
                </ColumnValidationSettings>
            </telerik:GridBoundColumn>

1 Answer, 1 is accepted

Sort by
0
Vasko
Telerik team
answered on 05 Aug 2024, 07:38 AM

Hello Ken,

Please try setting the column's Visible property to false, instead of the Display property. Visible is used through the server side to determine whether or not an item should be rendered to the page, while Display changes the CSS style to 'display: none'.

<telerik:GridBoundColumn DataField="CallLogID" UniqueName="CallLogID" HeaderText="CallLogID" Visible="False" />
<telerik:GridBoundColumn DataField="FollowUpCount" UniqueName="FollowUpCount" HeaderText="FollowUpCount" />
<telerik:GridTemplateColumn HeaderText="Follow Up" UniqueName="FollowUp">
    <HeaderStyle Width="22%" />
    <ItemStyle Width="22%" />
    <ItemTemplate>
        <asp:LinkButton ID="lnkFollowUp" runat="server" ToolTip="Follow Up">
                (<%# Eval("FollowUpCount") %>) view
            </asp:LinkButton>
        <asp:Literal ID="separator" runat="server" Text=" | " />
        <asp:LinkButton ID="FollowUpAdd" runat="server" Text="add" ToolTip="Follow Up"
            OnClientClick='<%# "openFollowUpAddWindow(" + Eval("CallLogID") + "); return false;" %>' />
    </ItemTemplate>
</telerik:GridTemplateColumn>
function openFollowUpAddWindow(callLogId) {
    var url = 'addfollowuptocalllog.aspx?calllogid=' + callLogId;
    window.open(url, '_blank');
}

Regards,
Vasko
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources
Tags
Grid Window
Asked by
Ken
Top achievements
Rank 1
Answers by
Vasko
Telerik team
Share this question
or