How to select a row in kendogrid after filtering - select

I have a kendogrid. What I do is first filter it, which works fine.
After having it filtered, I want to select a specific row. I am sure I have the row in the result of the filter.
Example:
data = id=a1, id=a2, id=a3, id=a4, id=a5, id=a6
filter result:
id=a2, id=a4, id=a6
I would like to select the row a4.

First of all loop through the Grid's data which is currently displayed (i.e.
var arrayOfModels = $('#GridName').data().kendoGrid.dataSource.view();
next add the k-state-selected class to the row you want to make it selected
$('#GridName tbody [data-uid='+model.uid+']').addClass('.k-state-selected')
where model is the record from the arrayOfModels above which you need

Related

How To Take Left Side String From A Particular position using PostgreSql

I have a table in that table there is a column called eq1.sources in that column, entries are like mentioned below. Now I would like to extract the string from the left side to till card slot number only.
Example:
fdn:realm:pam:network:55.150.40.841:shelf-1:cardSlot-1:card:daughterCardSlot-1:daughterCard
for this entry I need only
fdn:realm:pam:network:55.150.40.841:shelf-1:cardSlot-1
similarly
fdn:realm:sam:network:35.250.40.834:shelf-1:cardSlot-1:card
for this entry I need
fdn:realm:sam:network:35.250.40.834:shelf-1:cardSlot-1
I have tried substring(eq1.sources,0,position (':card:daughter' in eq1.sources)). this is working only for row numbers 1,2,4,5,6,7,9,10 but row number 3,8,11 not working as the entries not continued with ':card:daughter'.
The column name for the below entries is eq1.sources.
1.fdn:realm:pam:network:55.150.40.841:shelf-1:cardSlot-1:card:daughterCardSlot-1:daughterCard
2.fdn:realm:pam:network:35.250.40.824:shelf-1:cardSlot-1:card:daughterCardSlot-1:daughterCard
3.fdn:realm:sam:network:35.250.40.834:shelf-1:cardSlot-1:card
4.fdn:realm:pam:network:55.159.40.994:shelf-1:cardSlot-2:card:daughterCardSlot-1:daughterCard
5.fdn:realm:pam:network:35.250.140.104:shelf-1:cardSlot-2:card:daughterCardSlot-1:daughterCard
6.fdn:realm:pam:network:55.170.40.1:shelf-1:cardSlot-2:card:daughterCardSlot-1:daughterCard
7.fdn:realm:pam:network:35.450.40.24:shelf-1:cardSlot-3:card:daughterCardSlot-1:daughterCard
8.fdn:realm:sam:network:35.250.40.14:shelf-1:cardSlot-3:card
9.fdn:realm:pam:network:55.150.40.854:shelf-1:cardSlot-4:card:daughterCardSlot-1:daughterCard
10.fdn:realm:pam:network:35.250.40.84:shelf-1:cardSlot-5:card:daughterCardSlot-1:daughterCard
11.fdn:realm:sam:network:35.250.40.84:shelf-1:cardSlot-6:card
Expecting a PostgreSQL query to extract left side substring from a particular position in a row.
Expected output is
1.fdn:realm:sam:network:35.250.40.834:shelf-1:cardSlot-1
2.fdn:realm:sam:network:35.250.40.14:shelf-1:cardSlot-3:card
from
1.fdn:realm:sam:network:35.250.40.834:shelf-1:cardSlot-1:card:daughterCardSlot-1:daughterCard
2.fdn:realm:sam:network:35.250.40.14:shelf-1:cardSlot-3:card
First split the string into an array with : as a delimiter (this is the t subquery) and then pick the first 7 array elements and join them again into a string with : delimiter.
select array_to_string(arr[1:7], ':') as sources
from
(
select string_to_array(sources, ':') as arr
from the_table
) as t;
See demo.

Creating a For loop that iterates through all the numbers in a column of a table in Matlab

I am a new user of MatlabR2021b and I have a table where the last column (with name loadings) spans multiple sub-columns (all sub-columns were added under the same variable/column and are threated as one column). I wanto to create a For loop that goes through each separate loading column and iterates through them, prior to creating a tbl that I will input into a model. The sub-columns contain numbers with rows corresponding to the number of participants.
Previously, I had a similar analogy where the loop was iterating through the names of different regions of interest, whereas now the loop has to iterate through columns that have numbers in them. First, the numbers in the first sub-column, then in the second, and so on.
I am not sure whether I should split the last column with T1 = splitvars(T1, 'loadings') first or whether I am not indexing into the table correctly or performing the right transformations. I would appreciate any help.
roi.ic = T.loadings;
roinames = roi.ic(:,1);
roinames = [num2str(roinames)];
for iroi = 1:numel(roinames)
f_roiname = roinames{iroi};
tbl = T1;
tbl.(roinames) = T1.loadings(:,roiname);
**tbl.(roinames) = T1.loadings_rsfa(:,roiname)
Unable to use a value of type cell as an index.
Error in tabular/dotParenReference (line 120)
b = b(rowIndices,colIndices)**

Is there a way to work with records that you marked in table on X++?

I want to work with table records that is selected (Marked), Example - I have 10 records in table and i mark 5 of them. Expected - when i work with selected records, it should look only on that 5 records, not whole 10.
So far i have this code that selects all records:
while select Table
where table.JournalId == table.JournalId
Is there a way to make it select only marked records, not everything?
That select is writen in class. I need to get those marked records into that class where that select is writen...
You need to pass the formdatasource object into the class that is selecting the records, and then use the MultiSelectionHelper to loop through the selected records on the formdatasource.
In the example below, the object salesTableFormDataSource needs to be passed in from the form to the class you are using. Obviously replace that with whatever your datasource/table needs are.
MultiSelectionHelper selection = MultiSelectionHelper::construct();
selection.parmDatasource(salesTableFormDataSource);
SalesTable salesTable = selection.getFirst();
while (salesTable)
{
//do something with your table buffer.
salesTable = selection.getNext();
}

How to split same record in Form Grid?

I need to split the same record two time.
For example, if I have in MyTable five record I need to show in Form's Grid ten record.
If It's possible I can create a View, I just to duplicate one time the same record.
This is my start point :
I want to duplicate the record :
In MyForm can't edit anything, is only View. No Delete, No Edit, No Create
Thanks in advance!
This sounds like an exercise, which we probably shouldn't be giving you the answer to...but try creating MyTableJoin and create a foreign key relation to MyTable.Id then add a field called MyTableJoin.Row and populate the table with 2 matching rows for every 1 row in MyTable. Then on your form, join MyTableJoin.
So:
MyTableJoin.clear();
MyTableJoin.Id = "ID_I";
MyTableJoin.Row = 1;
MyTableJoin.insert();
MyTableJoin.clear();
MyTableJoin.Id = "ID_I";
MyTableJoin.Row = 2;
MyTableJoin.insert();
MyTableJoin.clear();
MyTableJoin.Id = "ID_II";
MyTableJoin.Row = 1;
MyTableJoin.insert();
MyTableJoin.clear();
MyTableJoin.Id = "ID_II";
MyTableJoin.Row = 2;
MyTableJoin.insert();
You can create a union view and add same table twice. Just be shore to select union all option so that you do not get unique results.

how to access one by on value of the stored procedure and calculate the average of them row wise

I executed a stored procedure in java which results into a table of 16 column and 3600 rows.Now I want to access 3 column of the retrieved table in row by row fashion and calculate the average of all column in row wise fashion.To do this,I need to access values of columns one by one .How to do it. My code for accessing column is
while (rs.next())
{
a1=rs.getDouble(7);
a2=rs.getDouble(8);
a3=rs.getDouble(10);
sum +=(a1+a2+a3);
}
return sum/3;
but through this,i think i'am getting a total average of all the columns .But i need average of column row by row i.e average of all three column of first row,then second row ...like this.
You are indeed adding all the values from 3 columns and doing row by row addition.
If you want row by row, then for each entry that you get from database you need to store the result in a list like below and return it where needed:
List<Double> averageList = new ArrayList<Double>();
while (rs.next())
{
a1=rs.getDouble(7);
a2=rs.getDouble(8);
a3=rs.getDouble(10);
averageList.add((a1+a2+a3)/3.0);
}
return averageList;