what I'm trying to do is export the selected rows to Excel.
But if I use the SelectedItems property it gives me a collection of the selected rows but in the order that they were selected.
I don't want this.
I want to get a collection of the selected rows as they appear in my table (however they are sorted).
Is there a way to do this?
Do i nedd to get all the data from my table and check each row if it's selected or not and then do what I need?
(it's part of a very large system and i just started working on this. i've never heard of this component before and i don't know all of it's properties and yes, i have looked on MSDN and in the definition)
Any help is appreciated
Cheers
I solved this problem using the Sort() function.
GridEX.SelectedItems.Sort();
Related
Hi i have one Gridview with data. I have already applied sorting and filtering option to Gridview. But i don't want to sort and filter my last 2 rows of Gridview. Please suggest me what can i do for it? . Thankx in advance
In asp.net gridview one property is provided by .net. Which is called as custom sorting.
By custom sorting method. you have to slice bottom two rows and sort the 1st half of data and append 2nd half sliced row. Return as a set.
For reference Custom sorting in grid view by MSDN
Thanks #Kiran Potawale, English is not my first language, If any grammatical mistake please ignore or edit into my answer.
Just don't set the SortExpression on those columns you don't want to Sort on.
I'm working with a DevExpress 14.1 GridControl on WPF, which must bind to a dynamic source. We don't know the number of columns or rows on design time, so this must be calculated on the fly.
The source may be changed while executing, adding more rows, or columns, or BOTH (I could have a table with 3 columns and 5 rows, and a 6th row with 4 columns could be inserted, adding a new column to the model with empty data for the previous rows).
I was using a DataTable as ItemsSource for the grid, but it will only load data inserted on design time. If I add columns while running the app, the grid wont update for some reason.
Is there an observable object that can satisfy this needs?
It's using code-behind (not MVVM) and maybe you already tried it, but have you tried explicitly calling myGrid.RefreshData() in your .xaml.cs file? There'd be some hook-ups to get it to call at the right times depending on your data changes, but it might at least help you narrow in on the problem if it helps or not.
DevExpress support answer here may help also.
Changing from a DataTable to an ObservableCollection may also do the trick: see this.
BTW, I've found DevExpress's support ticket system to be very helpful; they seem to respond within ~24 hours for issues and questions. If you're still able to get support for your license & can't solve it still, I'd ask them the same question here.
I have a gridview and sqldatasource.
I want to display in a label, the number of rows from the gridview which contains a certain value in one of the columns (in the form_load event)
I thought about looping through all columns of the gridview but it will take a lot of time for this and maybe there's another way of doing this.
Can someone help me finding the "other way"?
Thanks,
Best solution would be to let the database handle filtering - you'll get much better performance that way than looping over the data on application server.
Perhaps create another SqlDataSource with an SQL statement containing appropriate WHERE condition and bind it to your label?
I have used a ultragrid in my windows application to show records of a table of my database by set its DataSource property to the datatable that returns from that table.
the number of rows can be about 100000 rows.
Now i have 2 questions:
1) I want to let user to select several rows of this grid and then edit them all.to do this i need to know which cells of these selected rows have same values and which of them have not and then show the same columns in a form.
the first solution i thought about, was check all columns of all selected rows through 2 foreach loop.Is there any better solution for this??
2)finally when the user press save button, the updates should apply on the table.what is the best way to do this??? (Use IN command or UpdateCommand of sqldataadapter or ...)
According to my analysis,
1) you can do the grouping in the ultragrid based on which all columns you want to see and save the data. After grouping the similar columns would appear together and it will save a lot of time in data analysis and figuring out which column data are same in different rows. Once you have got the list of similar data you vcan handle them easily through for each loop or even for loop as you would be able to access the count of rows thus generated.
2) You should look at using the System.Data.SqlClient.SqlBulkCopy for this. Here's the documentation, and of course there are plenty of tutorials online.
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.aspx
One should avoid IN when no. of records are more as it affects the performance. If you dont want to use sqlbulkcopy, then you can also go for UpdateData() of ultragrid(very useful feature of ultragrid)
You can use the UltraGrid provided method call UpdateData() to update all the multiple rows with out need to track changes row by row or by cell
The UpdateData method updates any modified information in the grid, sending it to the data provider. When the update is complete, any rows that were marked as having modified data will have that mark cleared.
The UpdateMethod needs to exit from cells that are still in edit mode, this is a bug and to resolve it you will need to use it as shown below
ultraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.ExitEditMode);
ultraGrid1.UpdateData();
More details on why to use it this way can be found here http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.Aspx?ArticleID=4220
To answer you 2nd question you will have to use the UpdateData method this way
e.g.
private void ultraButton1_Click(object sender, EventArgs e)
{
ultraGrid1.UpdateData();
this.dbRowsTableAdapter.Update(this.testDataSet);
ultraButton1.Enabled = false;
}
Again it seems UltraGrid keeps its local data pure to itself hence you will have to call the Update method of the TableAdapter, which means you will have to create a DataSet and fill it with the SqlDataAdapter.
Please see forum explaining clearly why UltraGrid.UpdateData method does not commit back to database here http://www.infragistics.com/community/forums/t/57161.aspx
I could not find any solution for my first question so i have used loop to compare all selected rows of my grid and diagnose the common values.
but i have used SqlBulkCopy for my second question.
I want to copy data from flexgrid and I have a little problem. I am using filtering and I just want to copy selected data but It´s copy data which are “hide” (not show thx to filter). For example, I used filter and in flexgrid there are just few rows and I want to all copy so click to left upper cell and it select all shown rows but when I past it somewhere it past all rows (with that which arent shown). Same when select rows with Shift button.
How can I “fix” it? I know that´s normal and it´s not error but I need to change it and I hope that there is easy way to do that. Change some property or something like that.
But if there is not I actually dont have idea how to do that “hard” way. I was thinking that maybe use _c1FlexGrid.Rows.Selected and some way control if selected row is shown. But I dont know how.
Thanks for help
Edit
I figure out that if I change SelectionMode for flexgrid from Default to ListBox then I can use Rows.Selected and it has property Visible which I can check if row is shown or not. So I can thanks to this take just rows which are shown. But now I don´t know how can I add these rows to clipboard. Before I was using this:
Clipboard.SetDataObject(_c1FlexGrid.Selection.Clip);
but now I don´t now which class use to save shown rows and then at to clipboard. And there is problem with selecting because I like SelectionMode which was default (CellRange) and selecting just all rows it is not ideal. Any ideas?
Because no one else get with better solution I´ll write here mine. As I wrote in Edit in question there were problem with SelectionMode as CellRange. I still don´t know how to "fix" it with this mode but I figure out how to do it with ListBox mode.
So in flexgrid change mode to ListBox. Then you can use this in your copy method:
foreach (C1.Win.C1FlexGrid.Row item in _c1FlexGrid.Rows.Selected)
{
if (!item.Visible)
item.Selected = false;
}
Clipboard.SetDataObject(_c1FlexGrid.Clip);
I hope that this help someone else too :)