Page 1 of 2

How to programatically add/delete rows of a grid?

Posted: Thu Aug 16, 2012 2:56 am
by Jason Cochran

How do I programatically add/delete rows of a grid? Similar how you would do it with a list.

Let's say I have a field for the title and an "Add" button above my grid.

1) When I click the button a new row with two columns will be added to the grid.
2) The value of the title field is added to the left-hand column of the grid. The right-hand column of the grid will have a delete button.
3) When I click the delete button that row of the grid will be deleted.

Code to add rows to a list:

var list = Tiggr("mylist");
var title = Tiggr("txtTitle").val();
if(title == "") {
alert("You must enter a Title!");
return;
}
list.append("lia rel="nofollow"" + title + "/a/li").listview("refresh");
Tiggr("txtTitle").val("");

~ Jason


How to programatically add/delete rows of a grid?

Posted: Thu Aug 16, 2012 3:00 am
by Jason Cochran

What would also be nice is if there was a way to create a split list.

http://jquerymobile.com/test/docs/lis...


How to programatically add/delete rows of a grid?

Posted: Thu Aug 16, 2012 4:19 pm
by maxkatz

The Grid is our component, so just get the tr element and then duplicate it or delete it.


How to programatically add/delete rows of a grid?

Posted: Thu Aug 16, 2012 4:19 pm
by maxkatz

We'll add in our new HTML5 builder.


How to programatically add/delete rows of a grid?

Posted: Thu Aug 16, 2012 5:06 pm
by Jason Cochran

cool, thanks!

do you have any sample code for manipulating the grid (adding\deleting rows)?


How to programatically add/delete rows of a grid?

Posted: Thu Aug 16, 2012 5:23 pm
by maxkatz

Sorry, no. Use jQuery to select the elements in the DOM and then add/remove rows.


How to programatically add/delete rows of a grid?

Posted: Thu Aug 16, 2012 6:41 pm
by Jason Cochran

OK. So it is essentially a table?


How to programatically add/delete rows of a grid?

Posted: Thu Aug 16, 2012 6:42 pm
by maxkatz

Yes.


How to programatically add/delete rows of a grid?

Posted: Thu Aug 16, 2012 9:02 pm
by Jason Cochran

I have the code that adds rows to a grid working (which I will share later).

So how would I delete a row from a grid called myGrid?

Tiggr("myGrid tr:eq(1)").remove(); // this would delete the second row of the table

ref: http://stackoverflow.com/questions/58...


How to programatically add/delete rows of a grid?

Posted: Thu Aug 16, 2012 9:22 pm
by Jason Cochran

I have the code that adds rows to a grid working (which I will share later).

So how would I delete a row from a grid called myGrid?

the following does not work for me:

Code: Select all

  Tiggr("myGrid tr:eq(1)").remove(); 

ref: http://stackoverflow.com/questions/58...