DevExpress:How to programmatically remove a column from XtraReport? - devexpress

I have a Web application with XtraReport report. The report has several columns.
Depending on a certain condition, in certain situations I do not need one of the columns to exist. What is a best way to programmatically remove it? I need not to ‘make the column invisible’, but remove it. The space that the column occupied before the removal should be distributed evenly between the other columns.

A proper solution is to temporary remove the unnecessary XRTableCell from the XRTableRow.Cells collection...
Review the http://www.devexpress.com/issue=Q216567 discussion in the DevExpress support center. Hope this helps.

The easiest way to achieve this is to remove the cell from the row (for example on the report BeforePrint event). You should also wrap it in the suspend-resume layout code for the table itself:
private void TableReport_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
xrTable1.SuspendLayout();
xrTableRow1.Cells.Remove(xrTableCell1);
xrTable1.PerformLayout();
}

you can use dispose the cell
If CEHide.Checked = True Then
XrTableCell2.Dispose()

Related

How to disable pivot grid ordering in devexpress?

I am new in devexpress. I have data list to bind pivot grid. And I order my data list from SQL command. But as default pivot grid reoreder my data list to show.
I don't desire to reordered my list. Is it possible to ignore default ordering of pivot grid or some columns?
Source: How to disable default ordering of pivot grid ?
The cause of this behavior is that he pivot has it's own data engine
and has to sort data. Using the provided solution, you can sort field
values in a custom way, for example, using the order from the data
source.
Go through DevExpress thread - Disable Sorting in PivotGrid RowArea to more detailed information about the required functionality.
You can use the ASPxPivotGrid.CustomFieldSort event to sort data manually.
It is necessary to sort data manually by handling the ASPxPivotGrid.CustomFieldSort event. Do your calculation of sorting and grouping at this event. Below, I have posted a code snippet, demonstrating how to disable sorting:
private void pivotGridControl1_CustomFieldSort(object sender, PivotGridCustomFieldSortEventArgs e)
{
e.Result = e.ListSourceRowIndex1.CompareTo(e.ListSourceRowIndex2);
e.Handled = true;
}
References:
ASPxPivotGrid remove custom sort/order

reload table in WatchKit

We have a hierarchical watch app.
The root controller is a table of menu items. That list of items is controlled by a server. The data is retrieved and stored in core data. The menu is populated the first time going into the app.
But I want this table to stay current. My thought was to add code to willActivate to check if there was changes, and reload the table. In my reload logic I call the same function I called the first time, which sets the menuTable.setNumberOfRows and creates each row. Looking at what I'm putting in the logs, it is going through this logic with a different count of rows and new labels. But the app on the watch shows the table with the old data.
How can I get this table to reload with the new information?
I've had this problem too and as rmp says, it still seems to be a bug in watchOS 1.0.1. The problem appears when you try to reload your tableView after run willActivate() and nothing will happen.
In my case, I reload the tableView after receive a reply from a delegate and then I reload all the content just if it's necessary. To achieve this, I remove all rows from a NSIndexSet and load again.
if isNecessary {
self.table.removeRowsAtIndexes(NSIndexSet(indexesInRange: NSMakeRange(0, maxItems)))
isNecessary = false
}
I've tried a lot of tricks but none has worked for me:
Force to reload rows by table.setNumberOfRows(0, withRowType: "data")
Setting parameters to empty text before assign new values
One thing you could do is to hide tableView before removing rows, and avoid the remove animation.
It is a bug in WatchKit. Seems like Apple doesn't handle the repetitive interface object correctly.
The general principle here is: Only insert or remove necessary rows after a table is created. Do not reload the whole table like what we usually do in iOS. It just doesn't work (or trigger the bug).
So specifically, you have to:
Do this in willActivated method. This is correct.
If this is the first load, before the table is even created, do what you are now doing – load all table rows.
For all following times, don't reload the table, fetch the new data and check the desired number of rows.
Compare with the current number of rows in the table, insert to or remove from the bottom of the existing table.
Now simply re-assign the new data to all existing rows. Again, do not reload.
It should work if you follow the above steps.
I have found what works best given the current state of watchkit is to remove all rows then re-populate the table.
Try something like this:
- (void)loadTableData{
//clear the table
[mainTableView setNumberOfRows:0 withRowType:#"myTableRow"];
//set the row count again
[mainTableView setNumberOfRows:numberOfRows withRowType:#"myTableRow"];
//populate table
}
Its pretty simple. As Apple hasn't provided any method to reload the data.
You can still achieve that by simply populating the rows for the tableview.
Below is the sample code:
for index in 0..<tracksTableView.numberOfRows {
if let controller = tracksTableView.rowController(at: index) as? EditPlaylistRowController {
controller.playingTrackId = self.playingTrackID
controller.sharedTrack = trackItems[index]
}
}
Use it whenever you want to refresh the data.
NOTE:
You can still make some conditional statements inside the row controller class.
Happy to help :)

Flex 4 How do I access a specific cell by index?

I would like to edit a cell by the row and column indexes so essentially do the following:
advDataGrid[2][3] = "Dogs"
so that I am setting the data grid row 2 and column 3 to Dogs. I cannot for the life of me figure out how to do this!
Side note: I need this because I am trying to allow the user to copy a section of an excel file to a section of an AdvancedDataGrid like Google Docs does. I am using this idea to do it: http://mannu.livejournal.com/348299.html
Thanks! Any help will be greatly appreciated!
In general you want to operate on the dataProvider rather than the presentation (AdvancedDataGrid). So in your case, I would get the item associated with the specified row from your dataProvider and modify whichever element is specified to "Dogs". So something like this: adg.dataProvider[row].someColumnData = "Dogs"
EDIT: "someColumnData" refers to whatever property you have set for the column to display. So when you defined your AdvancedDataGrid's columns, you set the 4th column to use the "someColumnData" property of the items in your dataProvider, and you want to change the value in the 4th column, then you'd set it as described above. Hope that clarifies things.
Flex components are data driven, so you should modify the data provider of the grid.
What if you want to edit specific individual cells, eg I want to to keep running totals of some cells in other cells, IE: as a user edits I update whole columns.
Surely their must be a way to walk the array and get Column4.row6 = something.

Edit first column of GridView

I've got very dynamic GridView and I need to allow to user to edit first column of it. After he edit first column of grid it must be updated on DataBase.
Is there any ways to handle it ?
My only idea is to put some changeable element to first cell of each Row so it must be able to set / get my values for each row but can't find yet any examples of it ...
Additional info :
GridView takes data from Object data source and all columns are dynamic (yes, maybe except first, but I add it in dynamic way) and load complete DataTable... \
Currently Using jQuery+Ajax methode on dynamic button but can't disable button's PostBack so with a PostBack it just disappears and dont make the event it must to make...
Since you have dymanic columns, for each column, specify the read-only property (If a column is read-only, it may only be looked at, and not edited when in the GridView's Edit-Mode).
So, the first column of would be readonly="false" (or omit it entirely) and the other columns read-only="true".

Apply an ID to a GridView

Before you say it, I'm perfectly aware that a data repeater could do it, but I'm looking for the solution using a GridView.
I'm implementing a jQuery feature and require unique ID's to be applied to individual rows in order to respond to click events in the correct manner. I can't see how you're supposed to apply values to an ID or a row.
Basically I'm looking at doing something along the lines of
$('tr').click(function() {
// get the ID of the tr and redirect the page based on that
});
EDIT: Oh, and I can do it for a row cell if that's the value I want to pass as the query string, however, I don't want to do that as it'd mean displaying a unique identifier which is something the user shouldn't be able to see.
Okay, I didn't expect to actually solve my own question. Just for reference, here it is:
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.ID = e.Row.DataItem("Issue_Key")
End If
which is placed in the RowDataBound event.

Resources