Get Result sum from two devexpress gridview's Sum column - devexpress

i am using devexpress gridview 9.2.
i have 2 gridview having 2 colum --> Item & Rate. the Rate total is displayed on the footer for each gridview.
summary type="sum" is enabled for each grid.
i want to display result in a label.
The result is obtained from
the Sum of two gridview's FOOTER Sum colum .
Is this possible?

after both your Grids Are bound to DataSource, call the below method. However, Label cannot be updated if grids update via callbacks. in that case you need to use AspxCallback Panel, place 2 grids & label in Callback Panel, and PerformCallback on the CallbackPanel when grids need to be updated:
private void UpdateSummaryLabel(){
double rate1 = double.Parse(grid1.GetTotalSummaryValue(grid1.TotalSummary["Rate", DevExpress.Data.SummaryItemType.Sum]).ToString());
double rate2 = double.Parse(grid2.GetTotalSummaryValue(grid2.TotalSummary["Rate", DevExpress.Data.SummaryItemType.Sum]).ToString());
label.Text = String.Format("{0:n2}", rate1 + rate2);
}

Related

Display Image to RepositoryPictureEdit in gridView of DevExpress...?

I am working in DevExpress Gridview Concepts. I require one User Image in my grid field. i m working in winforms platforms.
My Datatable has only path of image. I dont know how to bind an image to repositoryPictureEdit Control
Kindly provide any solution.
You could using a ImageEdit. This is a dropdown of Images. So you generate Images first via:
Image.FromFile(Path);
Add them to a List or ImageList and fill the dropdown with it. Then you just bind the index of the picture to your column.
I hope this is able to work in your case.
edit: OR
At first you have to create a UnboundColumn in your Grid. Just create a column and set the Property 'UnboundType' to object. Then set a RepositoryPictureEdit as ColumnEdit. Now you have a Column which got a pictureedit in each row. To populate the Images you can handle the CustomUnboundColumnData event. This event you can find on the GridView.
To accomplish this task do following:
Run GridView Designer -> Change to columns at the left side
Add Column
In the Propertywindow ->
set the Columnedit to repositorypictureedit
set the UnboundType to object
Activate the CustomUnboundColumnData event (you can find in the
GridView) -> this event fires on loading Grid for every cell.
With e.ListSourceRowIndex you can get the row of your datasource appending to the unboundcolumn. So you could do following:
private void gridView1_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)
{
if (e.Column.Name == "MyColumn")
{
clsTest test = myListAsDataSource[e.ListSourceRowIndex];
e.Value = test.Bild;
}
}
I hope this can help you.

Get Total of Grid and Show on Label in DataList both Grid and Label are Inside DataList

I have a DataList. Label and Grid are Inside ItemTemplate of DataList i have Bound the Grid noe i want to show Total Of Grid Column in Label . Which is Placed in Parent control of Grid
You can Count the giridview columns by using this code:
int colCount = GridView1.Items[0].Cells.Count;

Devexpress ASPxGridView New Row Disabled

I have code like this with devexpress ASPxGridView. Everything goes well, but when I try to add new row, new row's textbox is disabled...
I have KeyFieldName set.
void BindGrid()
{
var AnnObj = SearchBarBanners.Select(i => new
{
Caption = i.Attribute("caption").Value,
ID = i.Attribute("id").Value, // this is generated by Guid
}).ToList();
ImagesGrid.DataSource = AnnObj;
ImagesGrid.DataBind();
}
I can suggest you two things without grid markup:
1. Call BindGrid method in Page_Init
2. If your datasource initially returns zero rows, grid won't be able to determine type of objects that will be rendered in grid. You need to use ASPxGridView.ForceDataRowType in order to solve this problem.
Use recommendations from the Q392961 DX Article to resolve this issue.

ASP.NET - How to remove dynamically added Gridviews from Asp:Panel

I am populating an Asp:Panel with gridviews generated dynamically based on user selection. As the user changes the selection criteria and the date, the panel to show the new gridviews based on the search criteria. I am doing MyPanel.Controls.Clear(), but the gridviews are still showing the old result. Then i tried the following, but still of no use, the panle is always showing the first result.
foreach (Control c in MyPanel.Controls)
{
if (c is GridView)
{
MyPanel.Controls.Remove(c);
//Response.Write("**"+c.ID);
}
// else
// Response.Write("##" + c.ID);
}
Response.Write("cnt=" + MyPanel.Controls.Count ); // Always showing as 1 even when the count is greater than 1.
Any idea how i can clean the panel each time before i try to populate the panel with new results as gridviews?
ray..
Why you are generating panel each time make one or two panel as you required and just change their content or set visible hide true or false as you required creating panel each time is not a good approach.

Flex Datagrid Sort

The default behavior of the Flex datagrid descending sort is that a selected row remains in view, meaning that the view will scroll down to show the selected row. I would like to change this so that when doing a descending sort the veiw remains at the top, with the selected row staying in the same position with a different row. I have tried different variations with this code but cant' get it to work:
var index:int = new int(myDG.selectedIndex);
var vertPos:int = myDG.grid.verticalScrollPosition;
myDG.selectedIndex = index;
myDG.grid.verticalScrollPosition = vertPos;
Thanks for your help. I am just beginning with Flex.
What you could try is the following:
Lets define newIndex as the desired index you want your datagrid to navigate to.
You could try something like this:
dgInstance.scrollToIndex(newIndex);
dgInstance.selectedIndex = newIndex;
The thing is that I didn't test the code so it might be necessary to add a:
dgInstance.validateNow();

Resources