elementi want to select a 3rd value from the drop down of 6 options and the code snippet for a single option as below: the div class is under the li class.
RELV-Indirect Tax
RELV-Indirect Tax
i dont want to select by id instead i want to pass the value as "RELV-Indirect Tax". how to do the same?
Try the following code and let me know.
Clicking on the dropdown will work for you I guess.
var selectdropdown = element(by.xpath("//select[#id='TaxProcessMod']"));
selectdropdown.click();
selectdropdown.all(by.xpath("//option[#class='ng-scope ng-binding']")).get(1).click();
OR
selectdropdown.all(by.className("ng-scope ng-binding")).get(1).click();
Related
I need a quick search filter, where user can select what columns are searched. I didn't succeed to implement this behavior.
I tried this:
this.columns.forEach(column=>{
if (this.globalSearchSelectedColumns.indexOf(column.field)>-1) column.getQuickFilterText = (params)=> params.value.name;
else column.getQuickFilterText = ()=> '';
});
this.grid.api.setColumnDefs(this.columns);
this.grid.api.onFilterChanged();
this.grid.api.resetQuickFilter();
where this.columns is columns defs, this.grid is gridOptions, this.globalSearchSelectedColumns is the selected columns to search for, by column.field.
In order to selectively apply quickFilter form ag-Grid you should rewrite the property getQuickFilterText of the columnDef, by setting it to a function which returns an empty string like so:
First of all, you need to retrieve the column by a key through the gridColumnApi
Then you need to access its colDef
Lastly, all you left to do is to rewrite getQuickFilterText property
Assume, that in your class component you have a method disableFilterCol it can look something like this:
disableFilterCol = () => {
var col = this.gridColumnApi.getColumn("athlete");
var colDef = col.getColDef();
colDef.getQuickFilterText = () => "";
console.log("disable Athlete");
};
Once it called, quickFilter will be applied to your data grid excluding athlete column.
I created live demo for you on ReactJS.
You can improve the way you can select multiple columns that you want to rely on doing filtering.
I suppose that in your case you can try to add set getQuickFilterText = () => "" for either definition of colDef from the very beginning and let the user enabling particular columns, you can set getQuickFilterText property for them to undefined to provide sorting among them.
According to nakhodkiin solution I change my code like this:
this.grid.columnApi.getAllColumns().forEach(column=>{
let def = column.getColDef();
if (this.globalSearchSelectedColumns.indexOf(def.field)>-1) def.getQuickFilterText = undefined;
else def.getQuickFilterText = ()=> '';
});
this.grid.api.onFilterChanged();
And it's working;
I think the problem here lies in setting updated column defs.
Can you try this -
let newColDef= [];
this.columns.forEach(column=>{
if (this.globalSearchSelectedColumns.indexOf(column.field)>-1)
column.getQuickFilterText = (params)=> params.value.name;
else column.getQuickFilterText = ()=> '';
newColDef.push(column);
});
this.grid.api.setColumnDefs(newColDef);
this.grid.api.onFilterChanged();
this.grid.api.resetQuickFilter();
this.grid.api.refreshHeader();
Ag-grid updated its approach of detecting column changes since v19.1
More details here
As per doc -->
When new columns are set, the grid will compare with current columns and work out which > columns are old (to be removed), new (new
columns created) or kept (columns that remain will keep their state
including position, filter and sort).
Comparison of column definitions is done on 1) object reference comparison and 2)
column ID eg colDef.colId. If either the object
reference matches, or the column ID matches, then the grid treats the
columns as the same column.
Ag-grid team is also actively working on fixing this issue for v20.1. You can track it on github
I have a w2ui form that contains a w2ui Drop List of choices. The choices will be different depending on what the user selected to bring up the form. My question is: can the contents of a Drop List be changed after it has been rendered?
With standard HTML controls, I would do something like this:
$("#mySelect option[value='xyz']").remove();
or
$("#mySelect").append('<option value="abc">abc</option>');
Can these kinds of operations be done with a w2ui Drop List? Any example code?
In w2ui 1.5 you can use $jQueryElement.w2field() to access the w2fild object - and then manipulate it.
Example:
var field = $("#my_input").w2field();
field.options.items = ["my", "new", "items"];
// optionally: pre-select first item
field.setIndex(0);
// if you do NOT use "setIndex" you need to call "refresh" yourself!
// field.refresh();
Note: setIndex() internally calls refresh() - so as stated above, you do not need to call refresh yourself in that case.
If you want to completely clear/empty your field, you can call field.reset().
Edit: after clarification that it's about a form field:
// Note: ``this`` refers to the w2form
// ``field[8]`` refers to a field of type "select"
this.fields[8].options.items = ["my", "new", "items"];
this.record = {
field_select: 'new'
};
this.refresh();
I use to fill my StringEdit a simple displayMethod.
This method selected to see some records from myTable and discard others , this method work well, but, in my Grid I see the empty records-rows(that would be the record discarded).
For to fill my StringEdit I used this dispaly method :
display myEXDTypeString nameFIeld()
{
MYTable mineTable;
myEXDTypeString name;
while select mineTable
where this.FieldtoUse== "Value"
name = this.NameFIeld;
return name;
}
There's a way to delete the empty rows?
In my Grid
I have a Lesf site state , I want to have the right situation:
Thanks all!
Enjoy
If you are just trying to get the Form to not display blank records then it could be as easy as setting a QueryBuildRange on the data source:
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRange;
super();
queryBuildDataSource = this.query().dataSourceName(mineTable_ds.name());
queryBuildRange = queryBuildDataSource.addRange(fieldNum(MineTable, FieldToUse));
queryBuildRange.value('>0');
I solved my problem: the cause is the Form DataSource relation.
OuterJoin Split my Lines.
Thanks all, enjoy!
I have been trying to find out an answer for some time and still nothing.
There are two select menus, they have the same amount of options and values. Say
Select A
"one"=>1
"two"=>2
"three"=>3
Select B
"one"=>One
"two"=>Two
"three"=>Three
Is there a way with Zend Form and validate to make them "synced".
So If I select SelectB=>Three, it automatically selects SelectA=>3 and vice-versa.
Or only with a custom validator?
The JavaScript solution works like this:
Modify your form.php
$A->setOptions(array('onchange'=>'mapIt(this.id)'));
$B->setOptions(array('onchange'=>'mapIt(this.id)'));
and
Add below JavaScript function to your view
function mapIt(id){
if(id == 'A'){
document.getElementById('B').value = document.getElementById(id).value;
}else{
document.getElementById('A').value = document.getElementById(id).value;
}
}
Not sure if this has been asked before, but I have an object (Restaurant) and I have a details view of that restaurant. On that details view, I want to have a list of cuisines that the restaurant offers. I want to also have a dropdownlist of the available cuisines and have the ability to click an "Add" button and it adds that cuisine to the Restaurant. I have a RestaurantCuisine table (using Entity Framework) that has a foreign key of the ID of the cuisine from a Cuisine table that has a primary key of ID.
So, now, my question, how do I do this? I sortof understand the concept behind the Create view and then the Create view post, but in this case, I'm not posting back the Restaurant object. So, how do I get the restaurant ID and the Cuisine ID so that I can add that to the restaurant cuisine collection?
Ok, so, now after investigating more, I believe I have asked the wrong question. My actual issue, is that I have a View that displays a Restaurant's details and I have a Details function in my controller for it. This works fine. The next step I want to do is have a dropdownlist with available Cuisines that this restaurant offers and have an 'Add' button next to it. And if you click on the 'Add' button, it adds the value of the item in the dropdownlist to the collection of cuisines setup in the Restaurant object.
Is this "easily" possible? I'm beginning to lose my faith in MVC2 :(
Ok, last try here. Let me ask this, does anyone know how to have a dropdownlist (I have now got this created) and have an "Add" button next to it, and get the selected value from that dropdownlist?
For those of you attempting to use VB.Net with MVC, I'm saying a prayer for you. It's rough. There are rarely any examples, and some syntax is not available that IS available in C#. So, as far as the answer to my original question. It seems as though it was my inexperience that caused the instant flare of the question.
After analying my problem, I figured out a way around it. First of all, let me clarify what I was attempting to do then explain what I did. The goal was to have an object (Restaurant in my case). And I wanted to have a list of properties (cuisines in my case) displayed on the Details view that I could assign to that object (Restaurant). The properties were cuisines that I had setup in a Cuisines table (CuisineId, Name, Description) and when you add a cuisine to a restaurant, it writes a record in another table RestaurantCuisine (RestaurantCuisineId, RestaurantId, CuisineId). So, getting the list of cuisines was the first task and have them display in a dropdownlist. That was done by creating a SelectList of cuisines in the Details view function by creating a CuisineRepository and calling a function that gets a list of all cuisines:
Dim cuiss As New CuisineRepository()
ViewData("Cuisines") = New SelectList(cuiss.FindAllCuisines().ToList(), "CuisineId", "Name")
Once you have this setup as a SelectList, it's easy to display that on the view by doing the following:
<h3>Cuisines:</h3>
<br />
<%= Html.DropDownList("Cuisines")%>
So, the problem after this was the real problem. I wanted to have an ActionLink that would be bound to the value of the DropDownList. I was unsuccessful in this attempt. But luckily, my jQuery is not dusty so I performed a little magic by doing the following:
<script type="text/Javascript">
$(document).ready(function () {
$('#Cuisines').change(function (e) {
$('#SelectedCuisine').val($('#Cuisines').val());
setHref($(this).val());
});
setHref($('#Cuisines').val());
});
function setHref(val) {
if (val) {
$("#addCuisine").attr('href', '/Restaurant/AddCuisine/' + $('#RestaurantId').val() + '?cuisineId=' + val);
}
}
</script>
<h3>Cuisines:</h3>
<br />
<%= Html.DropDownList("Cuisines")%>
<a id="addCuisine" href="">Add</a>
So, as you can see, I simply modify the href of the anchor as the user changes the selected Cuisine. Then, in my controller, I have a function setup to add a cuisine and to remove a cuisine from a restaurant:
Function AddCuisine(ByVal id As Guid, ByVal cuisineId As String) As ActionResult
Try
If ModelState.IsValid Then
'Dim selcuisInp As HtmlInputHidden = ViewData("SelectedCuisine")
Dim selectedCuisineId As Guid = New Guid(cuisineId)
Dim rc As New RestaurantCuisine
rc.RestaurantCuisineId = Guid.NewGuid
rc.RestaurantId = id
rc.CuisineId = selectedCuisineId
'rc.CuisineId = New Guid(selList.SelectedValue.ToString)
rc.CreatedDate = DateTime.Now()
'rc.CreatedBy =
db.AddToRestaurantCuisines(rc)
db.SaveChanges()
End If
Return RedirectToAction("Details", New With {.id = id})
Catch e As Exception
Dim innerE As String = e.InnerException.ToString
Return RedirectToAction("Details", New With {.id = id})
End Try
End Function
Function DeleteRestaurantCuisine(ByVal id As Guid) As ActionResult
Dim rc = (From rcs In db.RestaurantCuisines
Where rcs.RestaurantCuisineId = id
Select rcs).Single()
Dim rid As Guid = rc.RestaurantId
Try
db.RestaurantCuisines.DeleteObject(rc)
db.SaveChanges()
Return RedirectToAction("Details", New With {.id = rid})
Catch ex As Exception
Return RedirectToAction("Details", New With {.id = rid})
End Try
End Function
Notice the RedirectToAction. I had to pass the id of the object (Restaurant) that the Details view required and couldn't find the syntax anywhere. Finally, after a while of searching, found this site that the guy has a few examples of controllers and luckily he gives examples of both C# and VB. To add routeValues to the RedirectToAction, you declare a new list, and use an inline with and add your values with a period (.) preceding them:
Return RedirectToAction("Details", New With {.id = rid})
I hope this helps someone. It sure made the difference in my decision to use MVC. I am 100% sold even though I know I'm going to run into many roadblocks along the way.