I would like to do something similar what we do in ASP.NET where we parse through all the rows in a GridView and assign a particular value to a particular cell in a row which has a matching TaskId as the current Id.
This has to happen in a Tick function of a Dispatcher Timer object. Since I have a Start Timer button Column for every row in a GridView. Upon a particular row's Start Timer Button click, I have to start its timer and display in a cell in that row. Similarly there can be multiple timers running in parallel.
For this I need to be able to check the task Id of the particular task and keep updating the cell values with the updated time in all of the tasks that have a Timer Started.
TimeSpan TimeRemaining = somevalue;
string CurrentTaskId = "100";
foreach(GridViewRow row in RadGridView1.Rows) // Here I tried RadGridView1.ChildrenOfType() as well but it has null
{
if( (row.DataContext as Task).TaskId == CurrentTaskId )
row.Cells[2].Content = a.TaskTimeRemaining.ToString();
}
Can someone please let me know how do I get this functionality using the Telerik RadGridView?
Cheers,
Syed.
this works for me - using Telrik WinControls Q2 2009. I have this in the tick event of a timer.
foreach (GridViewRowInfo row in this.radGridView1.MasterGridViewTemplate.Rows)
{
if (row.Cells["colId"].Value.ToString() == CurrentTaskId)
{
row.Cells["colTimerValue"].Value = a.TaskTimeRemaining.ToString();
}
}
Related
I have a dropdown menu in A1 but I want it to reject input if B1 says "Closed". It won't let me keep the dropdown box as soon as I create the data validation for rejecting input. How do I fix this?
It is not possible to add 2 different data validation criteria in the selected range.
One workaround that you could do is to use data validation to have a drop-down menu and create an onEdit() function in Apps Script that will reject the inputs.
Sample Code:
function onEdit(e){
var cell = e.range;
var col = e.range.getColumn();
var ui = SpreadsheetApp.getUi();
//Check if current edited cell is in column 1 and if the cell besides the current cell is Closed
if(col == 1 && cell.offset(0,1).getValue() == "Closed"){
//Display warning message
ui.alert(
'Warning',
'You cannot modify cells that are closed, returning the original value of the cell',
ui.ButtonSet.OK
)
//return cell to its original value
cell.setValue(e.oldValue);
}
}
What it does?
Check if the modified cell is in column 1 and verify if the adjacent cell on its right has the value "Closed"
If true, display a warning message and return the cell to its original value
Output:
I used Range.offset(rowOffset, columnOffset) to get the value of the cell on the right side of the current cell by using +1 as column offset.
Additional Reference:
Container-bound Scripts
Google Sheets events
I don't necessarily need code, but I would appreciate pretty specific steps/logic on how to handle my problem.
My initial view controller is a table view controller. It will show the individual timer value and display its counting down in the current cell. The timer value is retrieved from a separate regular view controller. This view controller contains a UIPicker and the timer value is calculated using the user-selected values from the picker.
I am having trouble with the logic for handling multiple timers in the tableviewcontroller. Each newly created cell should be assigned a new timer object that is created with the creation of that cell. This way, a specific cell uses the time value created with a specific UIPicker value. So far, I can only get it to where each cell uses the same timer value as the first cell that is created.
How do I tell a newly created cell located in my initial table view controller that it should only use the value created with its specific timer value selected by the user with the UIPicker located in the second view controller? How do I separate the timer values between cells?
You should never have a table view cell with logical implementations, so at the most, the interface of the cell should have a method called setTime, and you give it a String which it just assigns it to the label.
Now that this is cleared up, who should be doing the logic? I believe you can abstract the timer logic into their own objects, because it would be too much of a hassle for the table view controller to keep track of all the play/pause states, how much time has passed etc.
So the work that's left for table view controller is just to get the data (remaining time) from the timer objects, transform them into Strings (you might have formatting logic here that VCs should handle) then pass those strings to the cell.
The code would look like this:
var timerObject = timerObjectArray[rowNumber]
var timeRemaining: Date = timerObject.getTimeRemaining()
var timeString: String = convertToString(timeRemaining)
cell.setTimeString(timeString)
So now we try to figure out when/how to get the cells.
As for when, that would be your choice, I think a NSTimer.scheduledTimerWithInterval could work (be careful of retain cycle)
Now in the method you pass to the schedule to be run every cycle, you should have code like this:
self.tableView.beginUpdates()
var visibleCells = self.tableView.visibleCells
for cell in visibleCells {
var indexPath = self.tableView.indexPath(for: cell)
var rowNumber = indexPath.row
var timeRemainString = getTimeRemainingStringFor(row: rowNumber)
cell.setTimeString(timeRemainString)
}
self.tableView.endUpdates()
Hope this helped! I probably missed something so just ask
I think your problem is maintaining state for each row data. Since table view reuses the cell, it becomes a problem.
Save the state of the timers in an array in parent view controller.
Set that value in every call of cellForRowAtIndex.
Please use below instead of NSTimer.
Solution : 1
int64_t delayInSeconds = gameInterval; // Your Game Interval as mentioned above by you
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
// Update your label here.
});
Solution : 2
NSTimer.scheduledTimerWithTimeInterval(1,
target: NSBlockOperation(block: {...}),
selector: #selector(NSOperation.main),
userInfo: nil,
repeats: true)
I have the need to disable a button in my application provided nothing is selected or multiple rows are selected.
I created the following binding (extra code to debug it since it wasn't working)..
BooleanBinding singleDocIsntSelected =
Bindings.createBooleanBinding(() -> {
boolean result = documentTable.getSelectionModel().getSelectedItems().size() != 1;
return result;
}, documentTable.getSelectionModel().selectedItemProperty());
What happens to me is that when I select the first row, it fires, then if I CTRL + Click the same row, it fires again. So far all is well in the world. Then I Click the same row - nothing, or when I CTRL Click other rows nothing.
My button will stay in the wrong state.
However, if I also add a listener to the property:
ChangeListener<MyDTO> selectedItemsListener = (obs, ov, nv) -> {
boolean result = table.getSelectionModel().getSelectedItems().size() != 1;
System.err.println(result);
};
Then everything works properly.
Is there no other way to handle this?
You need the binding to be invalidated when the list of selected items changes, not when the selectedItem property changes. If one item is selected, that becomes the selected item: if you then select additional items, the selectedItemProperty will not change (it is still the first one selected out of all those selected).
Using your current idiom, just bind to the selected items list:
BooleanBinding singleDocIsntSelected =
Bindings.createBooleanBinding(() -> {
boolean result = documentTable.getSelectionModel().getSelectedItems().size() != 1;
return result;
}, documentTable.getSelectionModel().getSelectedItems());
or, more simply,
BooleanBinding singleDocIsntSelected =
Bindings.createBooleanBinding(
() -> documentTable.getSelectionModel().getSelectedItems().size() != 1,
documentTable.getSelectionModel().getSelectedItems());
Though it's probably cleaner to use Bindings.size() and IntegerBinding.isNotEqualTo():
BooleanBinding singleDocIsntSelected = Bindings
.size(documentTable.getSelectionModel().getSelectedItems())
.isNotEqualTo(1);
I am using the ASP.NET MVC Kendo grid.
On click of a button, I need to expand all the rows.
Here is the code for the same:
var row = $(this).closest("tr.k-master-row");
grid.data("kendoGrid").expandRow(row);
Where this and grid have been defined. This works well.
On expand of each row, the following event is called (for each row), as the detail template is bound:
.Events(events => events.DataBound("onInnerGridDataBound"))
function onInnerGridDataBound(e) {
//Do something here
}
My requirement is that after I initiate the call to expand all the rows, I have a few lines in the code, which should be executed only after all the rows have been expanded. So,
function expandAll()
{
var row = $(this).closest("tr.k-master-row"); //Step1
grid.data("kendoGrid").expandRow(row);"); //Step2
//Do something after the onInnerGridDataBound event is called for
every expanded row.
..................................
//Ideally should be step 4 to be executed, but executes immediately
//after step2
}
//Ideally Step 3 to execute, but executes last
function onInnerGridDataBound(e) {
//Do something here
}
I want to avoid using the setTimeout method, as I don't know how long it will take or any flags.
Hope to find an answer soon.
Thanks!
Have you tried this?
Not sure if it'd work here but it should be something like:
$.when(grid.data("kendoGrid").expandRow(row))
.done(function () {
//after completing expandRow event
})
.then(function() {
//something else
});
Again, this may not work at all since I'm not sure if kendoGrid events can be treated as deferred objects but it's worth a shot.
I have a table bind to a SQLContainer and a insert button (that insert a row in the table)
When the button is clicked it execute the below code of the listener:
Object itemId = table.addItem();
container.getContainerProperty(itemId, "cedula").setValue(cedulaS);
try {
container.commit();
table.select(itemId);
catch (UnsupportedOperationException e) { //bla }
The row is properly inserted BUT I want that automatically the row be selected but the select method is not working any idea?
EDIT:
The select(ItemId) is working and its select the row BUT for some reason the commit line make that the select(ItemId) didnt works. I think is because itemId is a temporary row, so when the commit is execute it disappear o lose its values.
This thread has the answer, thanks to #Teppo Kurki
https://vaadin.com/forum#!/thread/4268146
The problem is that itemId is a temporal row id so when the commit is executed iy changed the row id, so it must be implemented the below listener:
container.addRowIdChangeListener(new QueryDelegate.RowIdChangeListener() {
void rowIdChange(QueryDelegate.RowIdChangeEvent event) {
table.select(event.getNewRowId());
}
});
Ant we now can delete the table.select(itemId); in the initial post