jQuery complex selector : Hierarchy string variable - jquery-selectors

assume in #main div the table have id foo_userId which represent contents of user have id userId
I have to select table with userId 1234 with given id as variable
<div id="main">
<table id="foo_1234_m"></table> //select this
<table id="f0006458_m"></table>
<table id="f0001234_n"></table>
<table id="foo_9999_k"></table>
</div>
$('div#main>table#foo_1234_m')
// foo : string , 1234 : variable , m variable
//////////i'm trying something like :
var userId='1234'
var tableID='foo_' + userId // from this
$("div#main>table[id^='foo_1234']") // how to make this

It appears you have the correct selector syntax. So you can write the jQuery selector using the same string concatenation as in your example, e.g.:
var userId = '1234'
var tableId = 'foo_' + userId
var element = $("div#main>table[id^='" + tableId + "']")

Related

Repeat the columns using data-sly-repeat based on the number entered in the cq dialog. Columns are not repeating

I want to repeat the parsys in the columns based on the number of columns added in cq dialog. I can only get one column and the numbers of columns as entered
<div class="items">
<div data-sly-repeat="${grid.cols}" class="col col-lg-4 col-md-2 pt-2 pb-2">
<div data-sly-resource="${'content-{0}' # format=[colList.index], resourceType='wcm/foundation/components/parsys'}"></div>
</div>
</div>
</div>
carousel.js:
"use strict";
use(function() {
var properties = granite.properties,
colCount = properties.numberofcolumns ? properties.numberofcolumns : 3,
cols = '';
return {
"cols" : colCount
};
});
data-sly-repeat expects a list, not a number. You're only returning the number of columns. If you return an n-element list, data-sly-repeat will render an element for each item in the list.
It's a bit of a hack but in your carousel.js, you'd have to return an array with a list of values. The primary use case of data-sly-repeat (and data-sly-list) is to iterate over the elements of a collection returned by the underlying Java/JS code and output the properties of each item in the list. In your case, the only difference between the repeated div elements is the index.
use(function() {
var properties = granite.properties,
colCount = properties.numberofcolumns ? properties.numberofcolumns : 3;
var resultList = [];
for (var i = 0 ; i < colCount ; i++) {
resultList.push(i);
}
return {
"cols" : resultList // data-sly-repeat expects a collection
};
});
On a more general note, it seems what you're aiming to do is to include a bunch of paragraph systems by name to achieve some sort of column layout. Before attempting this, I would consider using the OOTB Layout Container component, which can be resized in Edit mode to fit any number of columns without any new development.

How to filtering information on the second page based on data on the first page in SAPUI5? [duplicate]

This question already has answers here:
XXX is a table without a header line and therefore has no component called "EBELN"
(2 answers)
Closed 2 years ago.
I have a table. The first field of this table contains ID data.
When I click the marked button, I go to the second page. And this page has a few tables below as well.
Like this...
I get ID data in the background while adding data to the second table.
All of the tables have different IDs. When I go to the second page, I want the fields with the same ID to appear.
For example, when I click on the line with ID 000001, ENG with ID 1 should appear on the second page.
I applied such a filter for this but it didn't work:
onPress: function (oEvent) {
// The source is the list item that got pressed
this._showObject(oEvent.getSource());
var sFilterData = this.getView().getModel("kisiselBilgiler").getData();//first table json model id
var aFilter = [];
aFilter.push(new Filter("perId", FilterOperator.EQ, sFilterData.Id));
var oBinding = this.getView().byId("lisanTable").getBinding("items"); //second table id
oBinding.filter(aFilter);
},
My kisiselBilgiler Json Model in Worklist.controller.js:
onInit: function () {
// <<<<<<<<< KİŞİSEL BAŞLANGIÇ
var kisiselData = {
Id: "",
İsim: "",
dTarih: yeni Tarih (),
Posta: "",
isAdrc: "",
Hakkinda: "",
Lisans: "",
Uyruk: ""
};
var oModel = new JSONModel (kisiselData);
this.getView (). setModel (oModel, "kisiselBilgiler");
}, ...
The table I want to bind in Object.view.xml:
<Table id="lisanTable" width="auto" items="{ path: '/lisanSet', sorter: { path: 'perId', descending: false }, filters: [{path: 'perId'}] }"
noDataText="{worklistView>/tableNoDataText}" busyIndicatorDelay="{worklistView>/tableBusyDelay}" growing="true" growingScrollToLoad="true"
updateFinished=".onUpdateFinished">
<columns>
<Column>
<Text text="{i18n>perLisan}"/>
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<Text text="{perLisan}"/>
</cells>
</ColumnListItem>
</items>
</Table>
My error:
How can I do it?
NOTE: Github link of the project: https://github.com/shrgrl/CVApp
That FM is expecting a single field, not a table column. You need to loop at lt_mbbez and pass a single record value into that FM at a time.
loop at lt_mbbez assigning field-symbol(<mbbez>).
CALL FUNCTION 'C14Z_MESSAGES_SHOW_AS_POPUP'
EXPORTING
i_msgid = 'ZSG_INFO_MSG'
i_msgty = 'I'
i_msgno = '000'
i_msgv1 = <mbbez>-mbbez
i_lineno = 1.
endloop.
The error message is funky because once upon a time you could declare a table with an implicit header line, and it would have the same name as the table (well you still can in some contexts, but you shouldn’t).

Sails JS, how to map request parameter to model?

I want to map json data from request.params to model in my controller class.
It have some action in controller before save model to database.
Does it has the solution to auto map json data to model object without manually do this?
var email = req.body.email;
var phone = req.body.phone;
If I understand your question correctly, then yes.
I'll often build forms like this:
<input type="text" name="data[email]" value="ex#example.com">
<input type="text" name="data[phone]" value="1234567890">
In your controller:
var data = req.param('data')
// data is now = {email : 'ex#example.com', phone : '1234567890'}
And when updating database:
User.create(data).exec(funtion(e,r){
console.log(e||r)
// if there is no error, object r should contain:
// {
id : <id>,
email : 'ex#example.com',
phone : '1234567890',
createdAt : <date>,
updatedAt : <date>
}
})

Select/Get html node from an element using D3

Let's say I have an html object called element that I create using bellow code:
var xmlString = "<div class="parent"><span class="child"></span></div>"
parser = new DOMParser()
var element = parser.parseFromString(xmlString, "text/xml");
// or simply using jquery
var string = "<div class="parent"><span class="child"></span></div>"
var element = $(string);
What I want to do is to select span.child from element using D3, not from the document. Using d3.select('span.child') will try to look for the <span class="child"></span> in the html document.
I checked the documentation and it says:
A selection is an array of elements pulled from the current document.
But I want to select not from the document but from the above element that I just created. Is there any way?
After a bit of debugging I found out that if element is a object, not string, then d3.select(element) will not look for the element in the document instead it will return the element itself.
for detailed info:
d3.select = function(node) {
var group = [ typeof node === "string" ? d3_select(node, d3_document) : node ];
group.parentNode = d3_documentElement;
return d3_selection([ group ]);
};

How to add a dynamic content in tabular format using repeater in Wicket

I am new to Wicket and am trying to add purely dynamic content in wicket.
I have a list of object TableDataValuesVO which has a String tableName and a map columnNamesAndValues (containing columnName And its value). Each object in the list represent different data records of different table (the size of columnNameAndValues differ for each object). As of now I am using repeatingview for columnName and Value.but it displays one columnName per row and below that one columnValue per row.
Class to generate this component:
Html:
<table wicket:id="applicationDataView">
Java:
boolean columnNameRendered = false;
applicationDataView = new RepeatingView("applicationDataView")
RepeatingView tableView = new RepeatingView(applicationDataView.newChildId());
RepeatingView columnNameView = new RepeatingView(applicationDataView.newChildId());
tableView.add(new Label(applicationDataView.newChildId(),tableName));
applicationDataView.add(columnNameView);
applicationDataView.add(tableView);
List<dataVO> dataForTable= applicationDataByTable.get(tableName);
for (DataVO dataVO: dataForTable)
{
RepeatingView columnValueView= new RepeatingView(applicationDataView.newChildId());
if (!columnNameRendered)
{
for (String columnName : dataVO.getColumnNamesAndValues().keySet())
{
columnNameView.add(new Label(tableName+columnName,columnName));
}
columnNameRendered = true;
}
for (String columnName : dataVO.getColumnNamesAndValues().keySet())
{
String columnValue = tableDataValuesForRecordVO.getColumnNamesAndValues().get(columnName);
columnValueView.add(new Label(applicationDataView.newChildId(),columnValue));
applicationDataView.add(columnValueView);
}
}
Actual result:
Table name1:
Column 1
Column 2
Column 3
Val11
Val12
....
Table name2:
Column 1
Column 2
Column 3
Column 4
Val11
Val12....
Expected Result:
Table Name1:
Col1 col2 Col3
val11 val12 val13
val21 val22 val23
Table Name2:
Co131 col32 Col33 col34
val11 val12 val13 val14
val21 val22 val23 val24
Please help in providing a solution to display the dynamic data?
You can use, for example, a ListView that draws a lot of DataTables. (side note:I think this will be not very fast, as you will generate loads of HTML. )
Java:
List<DataVo> dataVoList = ... //create your list of datavo's
add(new ListView<DataVo>("listview", dataVoList) {
protected void populateItem(ListItem<DataVo> item) {
DataVo dataVo = (DataVo) item.getModelObject();
final DataProvider dataProviderBasedOnVo = ... //create dataprovider here.
IColumn[] columns = ... //create columns here, based on the dataVo
item.add(new DataTable("table", columns, dataProviderBasedOnVo, 10));
}
});
HTML:
...
<div wicket:id="listview">
<table wicket:id="table"></table>
</div>
...