Rows in the grid view need to animate and move the contents from left to right automatically. by each interval.
i already tried with table form but in the div grid view it is not functioning:
Code for table row to animate:
const rows = Array.from(document.querySelectorAll('tr'));
function slideOut(row) {
row.classList.add('slide-out');
}
function slideIn(row, index) {
setTimeout(function () {
row.classList.remove('slide-out');
}, (index + 5) * 200);
}
rows.forEach(slideOut);
rows.forEach(slideIn);
Related
As stated in the title, I have noticed some weird behaviour with my Data Grid View control. The cell click event is supposed to load details from the rows into textboxes and datepicker controls. This works for some rows of the data grid view but other rows are outright ignored.
The code:
`
private void dataGridViewAdmin_CellClick(object sender, DataGridViewCellEventArgs e)//Textbox and datepicker field input automation
{
if (e.RowIndex == -1)
{
return;
}
//Automatically fills the text fields with the User's selection.
DataGridViewRow selectedRow = dataGridViewAdmin.Rows[e.RowIndex];
txtName_Field.Text = selectedRow.Cells[1].Value.ToString();
txtPhone_Field.Text = selectedRow.Cells[5].Value.ToString();
try
{
dataGridViewAdmin.Rows[e.RowIndex].Selected = true;
datepickerEnd.MaxDate = (Convert.ToDateTime(selectedRow.Cells[4].Value)).AddDays(+7);
datepickerEnd.MinDate = (Convert.ToDateTime(selectedRow.Cells[3].Value)).AddDays(+1);
datepickerStart.Value = Convert.ToDateTime(selectedRow.Cells[3].Value);
datepickerEnd.Value = Convert.ToDateTime(selectedRow.Cells[4].Value);
Booking_ID = Convert.ToInt32(selectedRow.Cells[7].Value);
lblID.Text = "Selected ID: " + Booking_ID;
lblID.Visible = true;
}
catch (ArgumentOutOfRangeException) //Catches exception thrown if user from rows of data that have values that are more than seven days apart.
{
if(datepickerEnd.MaxDate < datepickerEnd.MinDate)
{
datepickerEnd.MaxDate = datepickerEnd.MinDate.AddDays(+7);
}
}
`
I've set a breakpoint within the code to see if it breaks on cell click. It breaks for some cells and does nothing on others. Naturally, I've tried spamming the mouse in on the problem cells to no effect.
I've tried to sort the rows differently, still no change.
Your help with this question will be appreciated.
My problem is when I select many rows in radGridView (Telerik) and especially when I select rows in the bottom of the RadGridView. the scroll move to the top.
I need to fix the scroll position to be in the same position of the last selected row.
Thank you.
This is my code :
private void radGVToBeApproved_SelectionChanged(object sender, EventArgs e)
{
this.radGVToBeApproved.SummaryRowsTop.Clear();
this.radGVToBeApproved.SummaryRowsBottom.Clear();
GridViewSummaryItem summaryItemCount =
new GridViewSummaryItem(radGVToBeApproved.Columns[0].Name, "Total rows : {0}", GridAggregateFunction.Count);
GridViewSummaryItem summaryItemSelectedRowsCount =
new GridViewSummaryItem(radGVToBeApproved.Columns[0].Name, " Total selected rows : {0}",
radGVToBeApproved.SelectedRows.Count.ToString());
GridViewSummaryRowItem summaryRowItem =
new GridViewSummaryRowItem(
new GridViewSummaryItem[] { summaryItemCount, summaryItemSelectedRowsCount });
this.radGVToBeApproved.SummaryRowsTop.Add(summaryRowItem);
this.radGVToBeApproved.SummaryRowsBottom.Add(summaryRowItem);
}
I have a table layout panel in my winform, and I want to add an effect to the rows whenever the mouse is hover a row.
I think I need to make a Mouse_over action over the table, and then detect the row number of the table, and then iterate on each cell on the row and change it's back color.
The problem is that I don't know how to get the row number.
Any ideas please?
EDIT: I am adding rows to the table dynamically, I have set of buttons and when I click one it deletes all old rows from the table and adds new rows that are related to this button.
This is the way I add new rows:
tlp.RowCount++;
tlp.RowStyles.Add(new RowStyle(SizeType.AutoSize));
tlp.Controls.Add(new Label() { ... }, cellIDX, rowIDX);
// adding more columns //
and to remove old rows I loop through all rows from bottom to top, removes all related controls of current cell, then I remove style and row num like so:
tlp.RowStyle.RemoveAt(rowNum);
tlp.RowCount--;
Here is what you can do:
As there actually are no Cells in a TableLayouPanel all you can do is
detect where th mouse is
paint the TLP in the CellPaint event.
Since your TLP most likely will contain controls they also need to detect whether the mouse is on them..
Here is an example:
First a class level variable to store the current row:
int tlpRow = -1;
Next a CellPaint event that can color a row:
private void tableLayoutPanel1_CellPaint(object sender, TableLayoutCellPaintEventArgs e)
{
if (e.Row == tlpRow)
using (SolidBrush brush = new SolidBrush(Color.FromArgb(123, 234, 45, 67)))
e.Graphics.FillRectangle(brush, e.CellBounds);
}
Next we need detection routines. First one for the TLP:
bool testTLP(TableLayoutPanel tlp, Point pt)
{
var rs = tableLayoutPanel1.RowStyles;
var rh = 0f;
for (int i = 0; i < rs.Count; i++)
{
if (pt.Y > rh && pt.Y <= rh + rs[i].Height )
{
if (tlpRow != i)
{
tlpRow = i;
tableLayoutPanel1.Invalidate();
return true;
}
}
rh += rs[i].Height;
}
tlpRow = -1;
return false;
}
It loops over all rows and adds up the heights until it has found the right one. Then it stores the row index and triggers the CellPaint event.
We can use the same routine for the controls:
bool testTLP(TableLayoutPanel tlp)
{
Point point = tlp.PointToClient(Control.MousePosition);
return testTLP(tlp, point);
}
We simply calculate the mouse position relative to the TLP and call the same test.
Note that this test only for 1 level of nesting. If you have deeper nested control you may need to expand on the test somewhat..!
We also need to call the tests; the TLP test can be called in the MouseMove:
private void tableLayoutPanel1_MouseMove(object sender, MouseEventArgs e)
{
testTLP(tableLayoutPanel1, e.Location);
}
The controls get hooked up all together maybe like this:
void hookUpControls(TableLayoutPanel tlp)
{
foreach (Control ctl in tlp.Controls)
{
ctl.MouseMove += (s, e) => { testTLP(tlp); };
}
}
I use the MouseMove event as the MouseEnter sometimes slipped through in my tests..
If you add controls later you need to hook the up as well. Make sure not to hook one up multiple times!
Most likely you want to reset the coloring when leaving the TLP:
private void tableLayoutPanel1_MouseLeave(object sender, EventArgs e)
{
Point tplPoint = tableLayoutPanel1.PointToClient(Control.MousePosition);
if (!tableLayoutPanel1.ClientRectangle.Contains(tplPoint)) tlpRow = -1;
tableLayoutPanel1.Invalidate();
}
Result:
Note: when you add Controls dynamically you need to hook the up as well. Here is an example:
Label lbl = new Label() { Text = "newbie" };
lbl.MouseMove += (ss, ee) => { testTLP(tlp, lbl); };
tlp.Controls.Add(lbl, cellIDX, rowIDX);
If you find the coloring flickers you can simply add a DoubleBuffered subclass:
class DoubleBufferedTLP : TableLayoutPanel
{
public DoubleBufferedTLP()
{
DoubleBuffered = true;
}
}
To do so you need to add to the project, compile, check to see it appears in the ToolBox. If you want to you can simply change the two sponts in the form_designer class..
I have a asp.net gridview that contains more than 100 rows. When I scroll down and select a row, the grid refreshes and automatically scrolls up to the first row. However, I can see the selected row in the colour I want when I scroll down. But the requirement is, it shouldn't scroll up automatically when I select a row. How do you prevent the gridview from scrolling up upon selecting the row.
I think we have some logic to refresh/databind on selected index change or selected row change.
EDIT:
My grid is inside an update panel.
I haven't tested this in isolation, but this is the code I'm using to achieve something similar
<script type="text/javascript">
var xPos, yPos;
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);
function BeginRequestHandler(sender, args) {
yPos = $get('<%= UpdatePanel3.ClientID %>').children[2].scrollTop;
}
function EndRequestHandler(sender, args) {
$get('<%= UpdatePanel3.ClientID %>').children[2].scrollTop = yPos;
}
</script>
I have to load a large amount of data to a dynamic grid view. Grid view having link button created dynamically based on data.
While clicking the link button, Inner Grid should be loaded. It is working fine.
But every time, on clicking the link button, on the Row bound event is fired, to bind the main grid.
With in the row bound event, inner grid is loading for each row in main grid , which is already clicked. i have maintain the clicked link button state(id field of the particular row) in Session, and using the session value , loading the inner grid on each row in main grid which is matched the session value in row bound event.
But loading takes long time. Is any other way to binding data to dynamic grid view on clicking the link button and maintain the clicked link button inner grid ?
My code is
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (strCallTypeName[intLoop].ToLower() != "total")
{
LinkButton lnk = new LinkButton();
lnk.Text = ((System.Data.DataRowView)(e.Row.DataItem)).Row[strCallTypeName[intLoop]].ToString();
lnk.CommandArgument = strCallTypeName[intLoop]
+ "|||"
+ ((System.Data.DataRowView)(e.Row.DataItem)).Row["UserId"].ToString()
+ "|||"
+ ((System.Data.DataRowView)(e.Row.DataItem)).Row["Service"].ToString()
+ "|||"
+ e.Row.RowIndex;
//lnk.Click += new EventHandler(lnk_Click);
//lnk.CommandName = "Edit";
lnk.Click += new EventHandler(lnk_Click);
lnk.ToolTip = strCallTypeName[intLoop];
lnk.CssClass = "lnk";
tc.Controls.Add(lnk);
string strUserID =grdSummaryCall.DataKeys[e.Row .RowIndex].Value.ToString();
string strSessionUserDetails = string.Empty;
strSessionUserDetails = (string)Session["GridUserDetails"];
if (strSessionUserDetails != string.Empty && strSessionUserDetails !=null)
{
string[] strSplitUserDetails = strSessionUserDetails.Split(new string[] { "~" }, StringSplitOptions.None);
Panel pnlTable = (Panel)e.Row.FindControl("pnlTable");
for (int i = 0; i < strSplitUserDetails.Length; i++)
{
string[] strUserDetails = strSplitUserDetails[i].Split(new string[] { "," }, StringSplitOptions.None);
if (strUserID == strUserDetails[1].ToString())
{
if (pnlTable.Visible == false)
{
GetUserCallDetails(strUserDetails, e.Row);
pnlTable.Visible = true;
}
}
}
}
}
}
Pooja, based on your comment above, I would make sure paging is working as expected and you are:
1 - only loading 30 records at time for the current page, not all of them and rendering
only 30.
2 - NOT calling again the database layer for each row binding; You can load all details for every single row of the page at once (so no more than page size, in your case 30), when loading the data for the current page, so your database calls would go down to 1 per page not 1 + pagesize == 31 in your case.