#tblEmployee td { padding: 2px; background: #e8edff; border-top: 1px solid #fff; ...", "image": "https://www.csharp.comUploadFile/MinorCatImages/043855AM.png", "author": { "@type": "Person", "name": "saifullah khan" }, "publisher": { "@type": "Organization", "name": "CSharp.com", "logo": { "@type": "ImageObject", "url": "https://www.csharp.com/App_Themes/CSharp/Images/SiteLogoNew.png" } }, "datePublished": "2013-08-16", "dateModified": "2013-08-16"} #tblEmployee td { padding: 2px; background: #e8edff; border-top: 1px solid #fff; color: #669; } #tblEmployee th { padding: 2px; color: #039; background: #b9c9fe; } function BindClientSideData() { //JSON data format var emps = [ { Name: \"John\", Designation: \"Analyst\", Age: 25, Department: \"IT\", DataSource: \"Client\" }, { Name: \"Matthew\", Designation: \"Manager\", Age: 38, Department: \"Accounts\", DataSource: \"Client\" }, { Name: \"Emma\", Designation: \"Senior Manager\", Age: 40, Department: \"HR\", DataSource: \"Client\" }, { Name: \"Sid\", Designation: \"Analyst\", Age: 27, Department: \"HR\", DataSource: \"Client\" }, { Name: \"Tom\", Designation: \"Senior Analyst\", Age: 35, Department: \"IT\", DataSource: \"Client\" } ]; BindTable(emps); } function BindServerSideData() { $.ajax({ type: \"POST\", url: \"JQueryGridTemplate.aspx/GetEmployees\", //pagename.aspx/WebMethodname data: \"{}\",// Blank data contentType: \"application/json; charset=utf-8\", dataType: \"json\", success: function(msg, status, metaData) { if (msg.d && msg.d.length > 0) { BindTable(msg.d); } }, error: function(ex, status) { //alert(ex.responseText); alert(\"error\"); }, complete: function(eret, tytyt) { //alert(\"complete\"); } }); return false; } function BindTable(data) { // removes existing rows from table except header row $('#tblEmployee tr:gt(0)').remove(); //apply tmpl plugin to
1
Answer

insert href in javascript grid

saifullah khan

saifullah khan

11y
1.4k
1
i have this code to show my data in javascript grid:
<pre lang="HTML"><%@ Page Language="C#" AutoEventWireup="true" CodeBehind="JQueryGridTemplate.aspx.cs"Inherits="JqueryGridDemo.JQueryGridTemplate" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>JQuery Grid Template Demo&lt;/title>

    <script src="jquery-1.8.3.min.js" type="text/javascript">&lt;/script>

    <script src="jquery.tmpl.js" type="text/javascript">&lt;/script>

    <style type="text/css">
        #tblEmployee td
        {
            padding: 2px;
            background: #e8edff;
            border-top: 1px solid #fff;
            color: #669;
        }
        #tblEmployee th
        {
            padding: 2px;
            color: #039;
            background: #b9c9fe;
        }
    </style>

    <script type="text/javascript">
        function BindClientSideData() {
            //JSON data format
            var emps = [
            { Name: "John", Designation: "Analyst", Age: 25, Department: "IT", DataSource: "Client" },
            { Name: "Matthew", Designation: "Manager", Age: 38, Department: "Accounts", DataSource: "Client" },
            { Name: "Emma", Designation: "Senior Manager", Age: 40, Department: "HR", DataSource: "Client" },
            { Name: "Sid", Designation: "Analyst", Age: 27, Department: "HR", DataSource: "Client" },
             { Name: "Tom", Designation: "Senior Analyst", Age: 35, Department: "IT", DataSource: "Client" }
            ];
            BindTable(emps);
        }

        function BindServerSideData() {
            $.ajax({
                type: "POST",
                url: "JQueryGridTemplate.aspx/GetEmployees", //pagename.aspx/WebMethodname
                data: "{}",// Blank data
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function(msg, status, metaData) {
                    if (msg.d && msg.d.length > 0) {
                        BindTable(msg.d);
                    }
                },
                error: function(ex, status) {
                    //alert(ex.responseText);
                    alert("error");
                },
                complete: function(eret, tytyt) {
                    //alert("complete");
                }
            });
            return false;
        }

        function BindTable(data) {
            // removes existing rows from table except header row
            $('#tblEmployee tr:gt(0)').remove();
            //apply tmpl plugin to &lt;script> and append result to table
            $("#employeeTemplate").tmpl(data).appendTo("#tblEmployee");
        }
   </script>

    <%--table row layout with data binding--%>
   <script id="employeeTemplate" type="text/html">
        <tr>
            <td> ${Name}</td>
            <td>${Designation}</td>
            <td>{{if Age>30}}
                <span style='background-color:red'>Middle-aged</span>
                {{else}}
                <span style='background-color:yellow'>Still young</span>
                {{/if}}</td>
            <td>${Department}</td>
            <td> ${DataSource}</td>
        </tr>
   </script>

</head>
<body>
   <form id="form1" runat="server">
    <div>
        <input id="btnClient" type="button" value="Bind Grid with Client Data" onclick="BindClientSideData()" />
        <asp:Button Text="Bind Grid with Server Data" runat="server" ID="btnServer" OnClientClick="javascript:return BindServerSideData()" />
        <br />
        <br />
        <table id="tblEmployee">
            <thead>
                <tr>
                    <th>
                        Name
                    </th>
                    <th>
                        Designation
                    </th>
                    <th>
                        Age
                    </th>
                    <th>
                        Department
                    </th>
                    <th>
                        Data Source
                    </th>
                       <th>
                        Data Source
                    </th>
                    <th>
                            <a id="btnSelectCustomer1" href=#">Select</a>
                        <a href=#">View Report</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <a href=#">Submit</a>
                    </th>
                </tr>
            </thead>
        </table>
    </div>
    </form>
</body></html>
</pre>


i want to put a link button at the last colm  each row. please tell me how to do it.
Thanks in advance
Answers (1)