How can I create filter component with multivalue react-table v7? - react-table

I create a Filter Component for react-table but when I do
setAllFilters([{id : 'columnID', value : ['element1','element2']}])
but it returns me no data ... but i know in my table I have rows with the value element1 or element2.

Related

Filtering table via Query builder - null value not selecting all

When my drop-down "filter" has no value selected, my table displays zero records. I need it to select all values.
The table is tied to Datasource1 containing fields:Name, Status, Team1, and Team2. I have a second Datasource called Teams that contains team names. I setup query builder for Datasource1 to change based on a radio button(status) and a dropdown(teamFilter).
Datasource1 - Query Builder:
status= :status and (team1 = :teamFilter or team2 = :teamFilter)
Selecting a value in the drop-down properly filters the table. The issue is when no value is selected, or if I select the null option.

How to get XML value from a column in SQL Server

I have a SQL Server table tblApplications with some columns... one of the columns is called Content and has XML values like in the following Image:
when i clicked on the value of content in the above image it displays like following in new tab
I want to get the value using id from the xml value of dataitem that is under the datagroupItem of datagroup as selected in following image, using query from the tblApplications
How to get the value from the content using id?? E.g. I want to get the value of id of dataitem = 'ForeNames'
How to get it using query????
You could try this query:
SELECT a.application_id,
x.y.query('.') AS DataItemNode,
x.y.value('(#type)[1]','NVARCHAR(50)') AS TypeAttr,
x.y.value('(#value)[1]','NVARCHAR(50)') AS ValueAttr
FROM dbo.tblApplications a
CROSS APPLY a.Content.nodes('/XmlDataPairDocument/dataitem/datagroup/datagroupitem/dataitem[#id="forenames"]') x(y)
or
DECLARE #id NVARCHAR(50);
SET #id='forenames';
SELECT a.application_id,
x.y.query('.') AS DataItemNode,
x.y.value('(#type)[1]','NVARCHAR(50)') AS TypeAttr,
x.y.value('(#value)[1]','NVARCHAR(50)') AS ValueAttr
FROM dbo.tblApplications a
CROSS APPLY a.Content.nodes('/XmlDataPairDocument/dataitem/datagroup/datagroupitem/dataitem[#id = sql:variable("#id")]') x(y)
Another similar questions-answers: here #1, here #2

Drupal - How to use Computed field in field collection item fields

I have custom content type type_a
Inside that custom type I have few titles
Title
Body
Group1 (field_group1) (Field Collection Item Can have multiple values)
Following are the details of fields inside Group1 (Field Collection Item)
Group Item 1 (field_item1) Can have one value
Group Item 2 (field_item2) (Computed field) Can have one value
I would like to copy value of "Group Item 1" field of same field collection item inside "Group Item 2"
Below is I am using in computed code:
$entity_field[0]['value'] = $entity->field_item1[LANGUAGE_NONE][0]['value'];
But it is not working. I am getting an error
Notice: Undefined index: value in eval() (line 1 of /homepages/13/d160804/htdocs/test/sites/all/modules/computed_field/computed_field.module(466) : eval()'d code).
Please help how to do this. Thanks
$entity->field_item1[LANGUAGE_NONE][0]['value'] contains the entity id of the field collection item (which contains the fields you want to copy).
You either need to load both field collection items and set their individual fields. Eg,
$source_fc = field_collection_item_load($entity->field_item1[LANGUAGE_NONE][0]['value']);
$dest_fc = field_collection_item_load($entity->field_item2[LANGUAGE_NONE][0]['value']);
// now set values of $dest_fc with values from $source_fc
Or do some sort of clone similar to this method: http://drupal.org/node/1233256#comment-5167316

Asp.Net MVC 3 ListBox will not select initial values

I am trying to set the initial values for a list box using asp.net mvc 3. It does fill in the options, but doesn't select them.
Here is my code. This attempt uses a hardcoded set of values
#Html.ListBoxFor(Function(model) model.PageTags, New MultiSelectList(Model.PageTags, "ID", "TagEn", New Integer(){1,2})
I have also tried an example that I would expect would select all the values.
#Html.ListBoxFor(Function(model) model.PageTags, New MultiSelectList(Model.PageTags, "ID", "TagEn", Model.PageTags)
You have to pass the selected values as an enumerable of "values" (and not an enumerable of the original "items"). In your case this should be a list of IDs. E.g. to select all try to pass the selected values like this: Model.PageTags.Select(i => i.ID)

Edit the code of a GridView column asp.net

I've been looking for a way to control the text that appears in a particular column of a GridView.
For example consider a database with two tables Student and Class.
I want to add a column to the GridView which print out all the students in the Database, the column will show the student's class name, how can do it? (I can normally print the ClassId since its a FK in the student table)
I want to add a column to the GridView which print all the classes, the column will count the number of students in each class, how can I do it?
1- You can do that simply with inner join or a stored procedure to get the class name beside all the data you need in your query.
2- More than one way to do what you want:
For example:
you can add a column to your data table (empty column ), and fill it later through using Sum() aggregate function in a query.
DataTable result_dt = DAL_Helper.Return_DataTable(sqlSelect);//your original query
result_dt.Columns.Add("NumberOfStudent");
result_dt.Columns["NumberOfStudent"].DataType = typeof(string);
result_dt.Columns["NumberOfStudent"].MaxLength = 255;
if (result_dt.Rows.Count > 0)
{
for (int i = 0; i < result_dt.Rows.Count; i++)
{
//Here u can fill your new empty column.
}
}
result_dt.AcceptChanges();
After you return your customized data table(as a data source), you can bind it to the grid view.
Another solution : add an empty column to the grid view and in the RowDataBound event of the grid view you can fill this column through some loop and you can use LINQ to help you in getting the summation.

Resources