How to mark a row in a datatable on button click? - button

I have a datatable with the first column containing a delete button for each row. When I click on that button, the "deleted" row is only marked for deletion (in a bean) until changes are saved (by clicking on "save" button). Meanwhile I would like to etc. change row color or remove the delete button in "deleted" row(s)... something to remind me that the row has already been marked for deletion. Any idea how to accomplish this?

Found a solution, simpler than I thought.
I made css file
.red{
background-color:rgb(250,165,200);
}
and added
rowStyleClass="#{item.rowState eq 'DELETED' ? 'red' : null}"
attribute in dataTable.
Works perfectly!

Related

Focusing the Row to be added in Inline Mode

I am trying to add a new row to the ASPxGridView in the inline mode. What I want is, when I click the 'New' button I want the new row that I am going to add, to have the focus, that is, the row should be highlighted. How can I accomplish this?
I have tried ASPxGridView1.FocusedRowIndex = -1; inside the InitNewRow event, but it doesn't highlight the row.
Any suggestions?
This links might guide you :
http://www.devexpress.com/Support/Center/p/Q260744.aspx
http://www.devexpress.com/Support/Center/p/Q259550.aspx
http://www.devexpress.com/Support/Center/Question/Details/Q356961

DataGrid does not update dataprovider on ItemEditEnd

In the following code, click a cell, change the text, then press tab and edit the next cell.
Only after moving to the third cell with another tab press does the first cell update.
Posting code here doesn't work well, so you can see it here:
http://forums.adobe.com/thread/794073
myDatagrid.executeBindings(false) does the trick.

select multiple gridview rows with Ctrl+Click?

Is it possible to select multiple gridview rows using Ctrl+Click and then delete all the selected rows with a button?
You can have a hidden field on the page that gets updated with each row ID in some sort of delimited list. Using jQuery, you can easily add a click event to each row that will add the ID to the hidden field on the client. After clicking a bunch of rows, the hidden field might look something like "3,65,245,111"
Here is a bit of jQuery to get you started. This will assign a click event to each row of a table with the ID "myTable":
$(document).ready(function() {
$('#myTable tr').click(function() {
//Insert your code to handle the click event and assign the row value to your hidden textbox
});
});
The above will make it so that you can handle each time a row is clicked. You'll need to write a bit of code and be creative to figure out how to get the ID of the clicked row.
A separate "delete all rows" button would take the value in the hidden field, split the string at each comma and then delete each row one at a time.
There are lots of different ways to skin this cat and the above is a quick and simple way to get the job done.

Adding a new row in between rows in a grid view

I have an ASP .net grid view. It has some template columns like a command button, a text box, and a dropdown control. When I click the command button, a new row needs to be inserted below the current row (from where I hit the command button).
If I have rows 1 and 2 and I hit the command button in row1 a new row needs to be inserted between rows 1 and 2
Now in the new row I should be able to select values from dropdown and enter some value in a text box and finally hit my save button. (Which should work fine as I am expecting)
The grid view is bound to some data source say for instance a datatable for now.
Oneway that I could think about is when Command button is clicked, I can add a new row to the datatable in my server side code and rebind the grid. But I am not sure that, from a UI perspective how I can make sure that the new row goes exactly below the row from where I hit the command button.
Any thoughts or comments?
I think a much easier approach will be if you try to add the row in your data source and then bind to the GridView again. This is easy if you have DataSet or a custom entity collection. Since, you are using DataTable this will also work. Handle the click event and find the row that the user clicked. Go back to the dataTable and add an empty row there. This will make sure that the controls inside the GridView are persisted and you don't have to worry about adding DropDown controls etc.
You have to sort the datasource by an virtual index saved in an invisible column. On first databound(perhaps you take a DataView because of ots sorting capability) it will set to the original rowindex. After first hit of the save button you get the datatable again from database and add the additional row with an index after the "selected" row. Then you bind the GridView again with the sorted DataView.
I think you need another invisible column to detect the "temporary" row. If you dont need to edit the "normal" rows then you can use edititemtemplate for this. Otherwise you can make the dropdown and textbox visible and the other controls invisible in GridView.OnRoawDataBound.
There is a code sample that is used for adding a new row in between rows in a grid view.

Flex edit DataGrid cell on click only when previously selected

I need to modify the behaviour of an editable datagrid to this:
-Single-click on a row, doesn't make the cell show a text input field (only selects the row)
-Double-click on a row, doesn't make the cell show a text input field either
but
-Clicking a cell in an already selected row, shows a text input field ready to be edited.
I belive this is how for example iTunes works.
I found a solution.
I ended up using the ListEvent.CHANGE to tell if the selectedIndex index had changed,
and then the preventDefault on ITEM_EDIT_BEGINNING if it was.

Resources