Still not seems to work in 2.1.78
Can you give me a working sample of a filled datagrid that adapt row height (and wrap content) by code?
Thank you,
Adrian
Hi Adrian,
it´s fixed in Wisej development build 2.1.78 that has just been released.
Best regards
Frank
Try the attached patch. Put in /Platforms or /Resources and set to Embedded Resource in AssemblyInfo uncomment the WisejResource attribute.
There is a regression in the javascript. Will fix in a dev build. I’m not sure I can have a patch before then.
Yes the LongTap is the tablet and mobile equivalent of the right click. I think the library converts a long click (press the mouse and keep it pressed) to a long tap on desktops. You can always check the environment using Application.Browser.Device (https://wisej.com/docs/2.1/html/T_Wisej_Core_ClientBrowser.htm).
OK – I have worked around it using the LongTap event (not sure this is correct). I also saw recommendations to use CellMouseUp rather than MouseClick (saves checking the cell is a cell, not a header or the white-space). My code for showing the ContextMenu is:
private void grdTests_LongTap(object sender, EventArgs e)
{
Wisej.Web.DataGridView.HitTestInfo htInfo = grdTests.HitTest(grdTests.PointToClient(Cursor.Position).X, grdTests.PointToClient(Cursor.Position).Y);int iRow = htInfo.RowIndex;
int iCol = htInfo.ColumnIndex;if (iRow >= 0 && iCol >= 0) // has to be a cell, not a header or after the last row
{
string sTestID = grdTests[“RECORDID”, iRow].Value.ToString();cmTest.Tag = sTestID;
cmTest.Show(grdTests, grdTests.PointToClient(Cursor.Position), null);
}}
I tried on 2.1.77. You have here a sample of code. Until 2.1.76 (included) that code works weird because of (sometimes big) not visible columns. Now it’s not working at all. I mean, nothing happens when I run that code with wrapText true/false.
Can you give me a working sample of a filled datagrid that adapt row height (and wrap content) by code?
Thank you,
Adrian
public static void AutoSizeTable(ref DataGridView dg, autoSizeTableMode tip, bool? wrapText = false)
{
try
{
var ds = dg.DataSource;
dg.DataSource = null;
switch (tip)
{
//bla-bla…
case autoSizeTableMode.Equal://user defined mode
for (int i = 0,nr_visible=0; i < dg.ColumnCount; i++,nr_visible+=((dg.Columns[i].Visible)?1:0));
for (int i = 0; i < dg.ColumnCount; i++)
dg.Columns[i].Width = dg.Width / nr_visible;
break;
//bla-bla…
default:
break;
}
if (wrapText != null)
for (int i = 0; i < dg.ColumnCount; i++)
dg.Columns[i].DefaultCellStyle.WrapMode = ((bool)wrapText ? DataGridViewTriState.True : DataGridViewTriState.False);
dg.DataSource = ds;
if (wrapText != null) dg.AutoResizeRows();
}
catch (Exception ex)
{
//bla-bla…
}
}
Hi Glenn,
#2319 is fixed in Wisej release 2.1.77
Best regards
Frank
Hi Adrian,
issue #2324 is fixed in Wisej release 2.1.77
Best regards
Frank
Perfect! Thank you again for you help!
See attached.
HTH
First: I managed to resolve with “independent” buttons. Meaning the standalone ones (I needed some time for me to understannd the concept).
Questions:
1. please give me a sample how to put this.getParent().u.upload() on ClientEvent, for execute, in code.
2. I have a DatagridView with a column template DataGridViewButtonCell. On code, it’s like:
var lc = new DataGridViewButtonColumn();
lc.CellTemplate = new DataGridViewButtonCell();
lc.DataPropertyName = dt.Columns[i].ColumnName;
lc.Name = dt.Columns[i].ColumnName;
lc.CellTemplate.Style.ForeColor = System.Drawing.Color.Navy;
dg.Columns.Add(lc);
When user click on cell, I have code on CellMouseClick event, and I want to initiate a file upload. Please give me a solution on how to accomplish that.
Or a way to initiate a file upload when click a cell, on a specific column.
Thank you for very quick reaction!
You cannot call u.UploadFiles() in Firefox, it will block the event. You need to call the event on the client side.
You can set all the properties in the designer. The only property that must be set in OnLoad is upload.Visible = true otherwise the client widget is not created for invisible controls until they are made visible once or used in a client call. If you send a small test case I can fix it for you.
You can attach client events to the dynamically created buttons using button1.ClientEvents.Add(…) or button1.AddClientEventListener()
https://wisej.com/docs/2.1/html/P_Wisej_Web_Control_ClientEvents.htm
https://wisej.com/docs/2.1/html/M_Wisej_Web_Control_AddClientEventListener.htm
I did what you told me, but I encounter 2 problems:
First one:
Without the u.UploadFiles(); called without effect on form.Load, at the first push of the button nothing happens. On the secont, third, etc it works. It’s a bug?
edit: step 3 this is not necessary; it’s stupid me! On button.Click no code is necessary, the javascript fires u.UploadFiles(); Still, withou calling u.UploadFiles(); on form.Load it’s not working.
Second problem (and that’s the big one):
I have tables (datagridview) with (some) columns as buttons (DataGridViewButtonCell). Some of them must upload files. I’m not sure how can I use that mechanism with dinamically created buttons? I mean the the event triggered is CellMouseClick. How can I attach a client side event to the button by code?
Thank you,
Adrian
You can also use the upload control directly and make it look like a button easily:
Set upload1.ShowValue = false.
If you want to change the colors or the icon you can.
If you want to use the same theme as a regular button set the AppearanceKey property to “button”.
The upload works well in all browsers. It’s the server-side triggering that is blocked by some browsers and some versions of the the browser because they don’t allow certain actions to be started without a user interaction (a click). The way to make it work is to attache a client side event to the button like the attached screenshot.
Also in your code you are creating a new upload control on each click, it will create a new <input> in the browser each time. You should create the upload control once. Drop it on the page and make it not visible on OnLoad().
If you enable the exceptions in VS and turn off “Just My Code” it will break exactly at the line of code that throws the exception. See screenshots attached. If it doesn’t break it means it’s not set up correctly.
Debug mode is turned in web.config
<system.web>
<compilation debug=”true” />
When that is on Wisej sends back the entire stack trace. In your screen shot it’s empty. Also the exception sent back should be displayed on the screen. Since it doesn’t there is something else wrong. Can you send me a link privately at support at wisej.com that I can try?
Following up for visibility. Replied in a comment section
UPDATE:
Once I added Application.CurrentDomain.FirstChanceException handler in WiseJ app, I can see what server side errors appears when this issue reproduced.
There’re 2 errors thrown: (my logger looks like: Log(“CurrentDomain_FirstChanceException error:” + e.Exception.ToString());
Unfortunately, the stack trace looks quite poorly 🙁
Contact sales at wisej.com.
We don’t have a SetStyle() method. If this is VWG code it cannot work with Wisej.
Use this.textBox1.CssStyle = “border:5px solid red”;
