handsontable propToCol returns property not column number - handsontable

I'm trying to use propToCol method in my handsontable grid. However, that method, which is supposed to return an integer is returning a string value of the property name instead if i try to alert the value of
#("grid").handsontable(propToCol ,prop);
How do I get the column number in such a case?

Ok so I found the problem and fixed the issue. I was using that method on a property that I was not displaying in the table(hidden property).So the propToCol method was not returning the column number.I put a check to ensure that that method is only applied to the properties i display in the handsontable grid.So it seems to work now.

Related

jqGrid method for posting specific cell

I have a grid with a method that calculates a value depending on different cells in the row.
I then set a specific cell to contain this value:
$("#gridID").setCell(rowid, "Cell_Name", myCalculatedValue);
I then want to finalize this by saving the value to the database but I cannot seem to find a method for this.
Basically what I want is
$("#gridID").saveCellToDataBase(rowid, "Cell_Name");
Since this cell is not the cell edited but a calculated value due to another cell being edited it's not saved by default.
I was hoping that methods that could solve my problem would be:
$("#gridID").jqGrid("saveRow", rowid, true);
or
$("#gridID").saveCell(rowid, "Cell_Name");
But none of these methods seem to do what I want.
If I understand correct you try to post a data to the server, but one (or more) field(s) is not editable and depend on calculation of other fields something like Quantity*UnitPrice.
As you know the not editable fields are not posted to the server and hence they can not be saved. In order to make this happen I see here two possible solutions.
Make the calculations at the server, without to post this value from jqGrid
Calculate the value in jqGrid and post it to the server
All of these have pro and cons, and I suppose that you can not make this calculation at server.
To post additional value to the server from editing depend on the editing method used - form edit, inline edit or cell edit.
Below I will describe a possible solution with inline edit and as exercise you will find it for other methods.
In jqGrid there is mechanism to post to post what you want to the server again with the edited fields. In our terms we name it serialization. This serialization happen before posting the data to the server and have different names depending on the editing module.
In case of inline edit this event is called serializeRowData and it is a grid parameter and not a parameter to the event.
In your case the code should like this:
$("jqGrid").jqGrid({
...
serializeRowData : function( data ) {
// suppose you have Qty and Unit field and want to post Total = Qty*Unit
if(data.Qty && data.Unit) {
data.Total = data.Qty*data.Unit;
}
return data;
}
Note the return at end of serializeRowData.
So this event execute every time you call saveRow, but this is well described in Guriddo documentation

Laravel - Model binding not working when I use accessors

I want to populate my select box from the Laravel IoC Container.
App\Http\Utilities\BillingHelper.php
views/billing/create.blade.php
views/billing/edit.blade.php
Create the table:
Now, instead of the value, i want to display some flags and currency symbols.
Should i use mutators?
Problem
If i use mutators, when i open the edit page, i see always the first value selected, from the BillingHelper, instead of the choosen one.
Any help? Thanks.
I know it should be a comment, but I have no reputation.
What if, on you edit page, you replace null on Form::select with $client->language and $client->currency.
I know that you area binding the values with Form::Model. But worth a try.
When you use mutators the matching won't occur anymore. You'll have to use a matching static array according to the values you'll return. (the flags)
You can make it work if you make a mutator for saving the data also and simplify again to the ['it', 'en', 'lv'], otherwise your saved data will differ and the initial mutator won't work the second time. You can still make a one-time-only test.
This is why:
Your form binding is using $bill->language to retrieve the actual stored data, and compare it with the values in your $bill::lang static array. If no match found, than the first value will be always selected.
Can you provide the the currency and language fields definition in the migration for the bill?
Also retrive your values from your bills DB and paste them here for language and currency. They must be in the defined static sets.
Laravel has a way of skipping the accessor/mutator by using
$model->getOriginal('data_field').
The "getOriginal()" gets the model's original attribute values.

Sitecore Item Validators

I created an item validator with the validation rule template. I'm using it to check if one field for a date is after another field for a date following this tutorial: https://sitecorejohn.wordpress.com/2010/03/17/validate-that-the-value-of-one-datetime-field-follows-another-with-sitecore. For some reason the item that is pulled with GetItem() in my validator does not have the change that the content editor has made until the item is saved. I thought Sitecore.Data.Validators.BaseValidator.UpdateItem would take care of this but it seems that my control to validate is null. That makes sense since it is an item validator instead of a field validator but that means that if this fires off on blur content editors may see false error messages or not see error messages when they should. I'm also running into an issue where my Evaluate method is firing twice on save; once before the item is actually saved so GetItem() returns with the non-updated values and once after save which has the expected values. If anyone has any insight as to why this might be happening I'd like to know. I have a feeling that the validator executing twice on save might be a config issue but I didn't see anything very obvious in the pipeline.
To get the new value of the field that's being validated you can use BaseValidator's
GetControlValidationValue();

Struts 1 Textbox to integer validation

In struts 1 if you try to bind a html:text field directly to an integer in the ActionForm then there isn't a chance to validate it correctly when the user enters a non-numberic value.
If the user enters a non-numberic value, then the integer value is always parsed as 0 before it reaches the validate method.
Is there any way supported way that struts provides to handle this situation? Or do I need to always bind to a String first and then parse into an integer later on?
If I am not mistaken, any thing that comes from the UI is a string, even though you have the variable defined as an integer in your form.
So my suggestion would be to declare the variable as string and parse it according to your need.

Kendo UI Datasource and Arrays

I am sending over a series of array values from a posted form to an MVC3 Controller. I was hoping the default modelbinder would be able to parse this but I'm having some difficulty with it.
The array is in the following format:
order[0].[type]=some value.
I think this is the reason the model binder is not parsing my values because I'm not getting anything populated in my model.
What would be another way to handle this?
Probably need to post more of your code so I can see what you are doing exactly. However saying this you need to pass the model to the view/partial view on the response you are trying to retrieve on the post request.
If not you will have to iterate through the Form Collection that will be returned and the Actions Methods type e.g. ActionMethodName(FormCollection form), one issue is name versus id its the name of the Kendo UI control that is used to get the value not the id.
1As far as I remember the right format was:
orders[0].OrderID=13;
orders[0].Name="test";
orders[1].OrderID=15;
orders[1].Name="again test";
The indexing should start from 0 and increase by 1.
Check this out: http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx

Resources