In this article I’m going to explain jQuery dynamically add and edit Table rows with jQuery UI dialog.

      This article is just for understanding purpose, how to add and edit table rows dynamically using jQuery with UI dialog. We have different ways to do this by jQuery. In this demo they have used jQuery UI dialog for enter data to HTML Table. Please follow the link for working demo

http://jsbin.com/amixeb/1/edit

Add jQuery library:

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" />

    <script src="http://code.jquery.com/jquery-1.8.3.js" type="text/javascript"></script>

    <script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js" type="text/javascript"></script>

 

Add script:

<script type="text/javascript">

        $(function () { 

            var new_dialog = function (type, row) {

                var dlg = $("#dialog-form").clone();

                var fname = dlg.find(("#first-name")),

            lname = dlg.find(("#last-name")),

            email = dlg.find(("#email")),

            password = dlg.find(("#password"));

                type = type || 'Create';

                var config = {

                    autoOpen: true,

                    height: 300,

                    width: 350,

                    modal: true,

                    buttons: {

                        "Create an account": save_data,

                        "Cancel": function () {

                            dlg.dialog("close");

                        }

                    },

                    close: function () {

                        dlg.remove();

                    }

                };

                if (type === 'Edit') {

                    config.title = "Edit User";

                    get_data();

                    delete (config.buttons['Create an account']);

                    config.buttons['Edit account'] = function () {

                        row.remove();

                        save_data(); 

                    }; 

                }

                dlg.dialog(config); 

                function get_data() {

                    var _email = $(row.children().get(1)).text(),

                _password = $(row.children().get(2)).text();

                    email.val(_email);

                    password.val(_password); 

                } 

                function save_data() {

                    $("#users tbody").append("<tr>" + "<td>" + (fname.find("option:selected").text() + ' ').concat(lname.find("option:selected").text()) + "</td>" + "<td>" + email.val() + "</td>" + "<td>" + password.val() + "</td>" + "<td><a href='' class='edit'>Edit</a></td>" + "<td><span class='delete'><a href=''>Delete</a></span></td>" + "</tr>");

                    dlg.dialog("close");

                }

            }; 

            $(document).on('click', 'span.delete', function () {

                $(this).closest('tr').find('td').fadeOut(1000, 

        function () {

            // alert($(this).text());

            $(this).parents('tr:first').remove();

        }); 

                return false;

            });

            $(document).on('click', 'td a.edit', function () {

                new_dialog('Edit', $(this).parents('tr'));

                return false;

            }); 

            $("#create-user").button().click(new_dialog); 

        });

    </script>

 

Add style:

<style type="text/css">

    body {

    font-size: 62.5%;

}

label, input {

    display: block;

}

input.text {

    margin-bottom: 12px;

    width: 95%;

    padding: .4em;

}

fieldset {

    padding: 0;

    border: 0;

    margin-top: 25px;

}

h1 {

    font-size: 1.2em;

    margin: .6em 0;

}

div#users-contain {

    width: 350px;

    margin: 20px 0;

}

div#users-contain table {

    margin: 1em 0;

    border-collapse: collapse;

    width: 100%;

}

div#users-contain table td, div#users-contain table th {

    border: 1px solid #eee;

    padding: .6em 10px;

    text-align: left;

}

.ui-dialog .ui-state-error {

    padding: .3em;

}

.validateTips {

    border: 1px solid transparent;

    padding: 0.3em;

}

#dialog-form {

    display: none;

}

    </style>

 

Add HTML code:

<body>   

    <div id="dialog-form" title="Create new user">

        <p class="validateTips">

            All form fields are required.</p>       

            <form>

        <fieldset>

            <label for="first_name">

                First Name</label>

            <select id="first-name">

                <option value="1">Arun</option>

                <option value="2">Ganesh</option>

                <option value="3">Suresh</option>

                <option value="4">Sanganabasu</option>

            </select>

            <label for="last_name">

                Last Name</label>

            <select id="last-name">

                <option value="1">Hulagabal</option>

                <option value="2">Cheemalamudi</option>

                <option value="3">Ganiger</option>

                <option value="4">Kattriguppe</option>

            </select>

            <label for="email">

                Email</label>

            <input type="text" name="email" id="email" value="" class="text ui-widget-content ui-corner-all" />

            <label for="password">

                Password</label>

            <input type="password" name="password" id="password" value="" class="text ui-widget-content ui-corner-all" />

        </fieldset>

        </form>

    </div>

    <div id="users-contain" class="ui-widget">

        <h1>

            Existing Users:</h1>

        <table id="users" class="ui-widget ui-widget-content">

            <thead>

                <tr class="ui-widget-header ">

                    <th>Name </th>

                    <th>Email </th>

                    <th>Password</th>

                    <th> Actions</th>

                </tr>

            </thead>

            <tbody>

                <tr> <td class="custom-name"> John Doe </td>

                    <td>john.doe@example.com</td>

                    <td>johndoe1 </td>

                    <td><a class="edit" href="">Edit</a> </td>

                    <td><span class="delete"><a href="">Delete</a></span>   </td>

                </tr>

            </tbody>

        </table>

    </div>

    <button id="create-user">

        Create new user</button>   

</body>

 

cytotec abortion

http://www.extrageek.com/template/default.aspx?an-abortion-pill buy abortion pills online
medical abortion pill online abortion pill abortion pill


View demo Download
http://www.dotnetfox.com/Document/1106/0Demo1.gif

If you enjoyed this article, get email updates (it's free).


Related Articles
  • How to create JQuery UI Accordion in ASP.NETIn this article I’m going to explain how to use JQuery Accordion in ASP.NET. Accordion displays collapsible content panels for presenting information in a limited amount of space. The markup of your accordion container needs pairs of headers and content panels. Here I’ll show you how to create JQuery UI Accordion in ASP.NET. First we have to use following JQuery library and StyleSheet
  • Show GridView row details in Tooltip on mouseover using JQuery in ASP.NETIn this article I’m going to explain how to show GridView row details in Tooltip on mouseover using JQuery in ASP.NET. About JQuery Tooltip plugin: The jQuery Tooltip plugin let’s you transform native tooltip’s into customizable overlays. You can adjust their content, position and appearance. Tooltips can be attached to any element. When you hover the element with your mouse, the title attribute i...
  • Google Geo Chart or Geo map with custom Color and Tooltip in ASP.NET I have already written an article for implementing Geo Chart in ASP.NET. In this article I’m going to explain how to use custom colors and tooltip in Google Geo Chart. In this demo I have implemented Geo chart for countries and percentage of world populations. For that first we have to create table with following fields.
  • Dynamic Accordion menu or Vertical menu using jQuery in ASP.NET MVCNavigation menu is most important in any web applications. While developing web applications, I used to create stuff more interactive by using jQuery and CSS. It’s quite different to create dynamic navigation menu in ASP.NET MVC. Whether it’s a horizontal or vertical menu, the idea remains same. This article will show you how to create jQuery Accordion menu dynamically in ASP.NET MVC web applicati...
  • JQuery vertical tabs example in ASP.NETIn this article I’m going to explain how to create JQuery vertical tabs in ASP.NET. When we consider user experience in ASP.NET application, JQuery is best option to fulfill user expectation. Easy responsive tabs enables you to create vertical tabs in web pages. You can download source code which is available along with this article.
  • JQuery sliding div from left to rightIn this article I’m going to explain how to create JQuery sliding div from left to right direction. JQuery is a powerful JavaScript library that designed to help with JavaScript programming. And it is a lightweight, "write less, do more", JavaScript library. The purpose of jQuery is to make it much easier to use JavaScript on your website. JQuery also simplifies a lot of the complicated things fro...
  • JQuery Check or uncheck all CheckBoxIn this article I’m going to explain how to check or uncheck all CheckBox or multiple CheckBox. It’s quite easy to do this by JQuery. I have done two examples, you can implement in your project based on requirement. 1.Check or uncheck all CheckBox on Checkbox click 2. Check or uncheck all CheckBox on Button click.
  • Get sum of multiple CheckBox values by using JQueryIn this article I’m going to explain how to count multiple Checkbox values by using JQuery. Can we do anything by using JQuery? Yes of Corse, I got one requirement that I have to get sum of multiple CheckBox values without any postback.
  • JQuery show hide multiple DIV specific time intervalIn this article I’m going to explain how to show/hide multiple DIV specific time interval by using JQuery. It’s quite easy to how/hide multiple DIV specific time interval by using JQuery. JQuery Show() and hide() function enables you to do this task with custom Fade In and Fade Out effect.
  • jQuery multiple checkbox values to comma separated stringIn this article I’m going to explain how to get multiple checkbox values output as comma separated string using jQuery. I got one requirement that I have to get multiple checkbox values output as comma separated string by using jQuery. Whenever I’m going to click checkboxes, the checkbox values should be added as comma separated string to textarea control.

Comments
comments powered by Disqus

Thanks for downloading..!!

×
Subscribe via Email
    
message to display in fancybox