Hi.
I am trying to follow the instructions in the Wisej_DevExtreme GitHub ReadMe to get the clicked Cell in the DxGrid. For that, I thought I would be able to access the dxGrid1.Widget.getCellElement with the rowIndex and columnIndex. However, intelisense doesn’t bring me any Widget object for the dxGrid1. Is this the proper way to access the method? From the docs, it states, as an example:
this.dxLinearGauge1.Widget.value(15);
Thanks in advance.
Ivan
You cannot return an HTMLElement to the server. It’s a browser object.
You can run javascript like this dxGrid1.Eval(“this.widget.getCellElement(…).style.border=’1px solid red'”);
Also, on the server side the dynamic property is “Instance”. We used “Widget” in the 2.1 version.
IntelliSense cannot show any JavaScript method, you have to use the vendor’s API reference.
Thank you.
This one worked fine:
var value = await this.dxGrid1.Instance.cellValueAsync(rowIndex, colIndex);
This one throws the exception “Unknown function: widget.cellValue”:
var value = await this.dxDataGrid1.CallAsync(“widget.cellValue”, lnRow, lnCol);
My mistake:
Getting a value back from the browser
If the remote js method you are calling returns a value and you want that value, you will receive it in an asynchronous callback because, being a remote call from the server to the browser (would be the same if it was from the browser to the server) it can only be asynchronous. Wisej supports it in both ways: callback or async/await.
this.dxGrid1.Call("widget.cellValue", (value)=>{ ...here I have value... }, rowIndex, colIndex); // or var value = await this.dxGrid1.CallAsync("widget.cellValue", rowIndex, colIndex); // Using the dynamic bridge (Instance) only support await/async: var value = await this.dxGrid1.Instance.cellValueAsync(rowIndex, colIndex);
Attaching to a dynamic event
Cannot use the method directly since it’s a dynamic object, do this:
this.dxDataGrid1.Instance.cellClick += new WidgetEventHandler(dxDataGrid1_WidgetEvent);
Thanks again! All very valuable information.
There is probably something I am still missing from my side:
This is working fine:
dxDataGrid1.Instance.cellValue(lnRow, “Job”, 234);
This is returning null:
var value = dxDataGrid1.Instance.cellValue(lnRow, “Job”);
Forgot, you can also attach to the cellClick event like this:
dxDataGrid1.Instance.cellClick += this.dxDataGrid1_cellClick;
private void dxDataGrid1_cellClick(object sender, WidgetEventArgs e) {
}
Basically the “Instance” member of the widget is a special dynamic JavaScript bridge to/from the browser. Any method you call on it will be called on the widget, any event you attach to it will handle the same event from the widget. There is no check at coding time (as in JavaScript) if anything exists since it’s all dynamic.
Yes, but you don’t need to call Eval with cellValue. The problem before was that you were using getCellElement() on the server which cannot return a DOM object to the server since it’s a browser object that cannot be serialized.
In the last sample you quoted you can do this:
dataGrid1.Instance.cellValue(lnRow, “Job”, “234”);
To read the value:
AlertBox.Show(dataGrid1.Instance.cellValue(lnRow, “Job”));
The method cellValue in the DX grid works for both setting and reading: https://js.devexpress.com/Documentation/ApiReference/UI_Widgets/dxDataGrid/Methods/#cellValuerowIndex_dataField_value
Hi Luca.
Thank you for the explanation. I was able to set some of the widget properties values as a test.
private void dxDataGrid1_WidgetEvent(object sender, WidgetEventArgs e)
{
if (e.Type == "cellClick" && e.Data != null)
{
int lnCol = e.Data.columnIndex;
int lnRow = e.Data.rowIndex;
dxDataGrid1.Eval("this.widget.cellValue(" + lnRow.ToString() + ", \"Job\", " + "\"234\")");
}
}
Now, is there a way to GET the Cell value, for example, from the server side?
Cheers.
Ivan
Please login first to submit.