Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I would like to achieve this in gridview:

http://bootsnipp.com/snippets/featured/dynamic-form-fields-add-new-field-on-focus-or-change[^]


I've implemented the following behavior, but would like to achieve it on a gridview:
-1.DropDown 1.TextField in a row.
-The cross sign appears next to TextField on all rows except the last row.
-New row[with 1.DropDown 1.TextField] gets added on focus of the last TextField.
-On clicking the cross-sign, the row gets deleted.

I think it's a bad implementation, and I have to maintain the id's of all the elements etc. I'm assuming gridview might be a cleaner approach.
Posted
Comments
F-ES Sitecore 26-Apr-15 6:24am    
GridViews are for displaying data bound on the server-side and it can generate code needed to manipulate that data. Server controls rarely work with custom client-script though. When you add rows to the data in a gridview your server code doesn't know about them. If you're looking to manipulate the data on the client you're better not using a gridview but a repeater to build the basic table html you need and you'll need to implement all the CRUD code yourself.

1 solution

XML
function GennrateRow(parameter1, parametr2) {
    try {

        return '<tr class="prototype" Active="1" runat="server" clientidmode="Static">' +
                                                '<td>' +
                                                    '<select class="form-control form-control-box col-lg-8 bxFloatleft ddlRole">' + field1+
        '</select>' +
                                                '</td>' +
                                               ' <td>' +
                                                    '<select class="form-control form-control-box col-lg-8 bxFloatleft ddlRoleType">' + field2+
        '</select>' +
                                                '</td>' +
                                               ' <td>' +
                                                    '<input type="text"  onkeydown="return false;" onpaste="return false;" ondrop="return false;" class="from form-control required-field form-control-box txtStartDate" />' +
                                                '</td>' +
                                                '<td>' +
                                                    '<input type="text" onkeydown="return false;" onpaste="return false;" ondrop="return false;" class="to form-control form-control-box hide txtEndDate" />' +
                                                '</td>' +
                                                '<td>' +
                                                '<span class="delete" style="cursor:pointer"><img src="../../Images/delete_form.gif" /></span>' +
                                                '</td>' +
                                             '</tr>';

    } catch (e) {
        console.log(e);
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900