SAP UI5 - Not able to select more than one Check box in Table column - hana

I have created a table with few columns getting data from Odata and i have created another column will have just check box.
My Code is
var oTable = new sap.ui.table.Table("Brand",{
title: "Brand List",
// visibleRowCount: 10,
//firstVisibleRow: 3,
selectionMode: sap.ui.table.SelectionMode.None,
navigationMode: sap.ui.table.NavigationMode.Paginator,
fixedColumnCount: 10,
width:"700px"
});
oTable.addColumn(new sap.ui.table.Column({
// visible: false,
label: new sap.ui.commons.Label({text: "Country"}),
template: new sap.ui.commons.TextView().bindProperty("text", "COUNTRY_ID"),
sortProperty: "COUNTRY_ID",
filterProperty: "COUNTRY_ID",
flexible : false,
width:"1px"
}));
//Define the columns and the control templates to be used
oTable.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({text: "Brand"}),
template: new sap.ui.commons.TextView().bindProperty("text", "BRAND"),
sortProperty: "CUSTOMER",
filterProperty: "CUSTOMER",
width:"250px"
}));
oTable.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({text: "2013",textAlign:"Center"}),
template: new sap.ui.commons.CheckBox().bindProperty("checked","checked"),
sortProperty: "checked",
filterProperty: "checked",
width: "100px",
hAlign: "Center"
}));
It works fine when the table length is 10 ( defined in the table creation statement). But if my brand list is more than 10 ( some times it can be more than 100) , still the no. of check boxes is created is 10. so in the table if go to next page (paginator mode ) , the check boxes are still the same.
So if i select a brand in first page and select a brand in third page , the check box remains same. Its not creating check boxes except for the first page.
Please help me on this issue.
Thanks
Sathish

Attempt 2. This time, I'll try answer the question. Sathish, it appears as though your model does not account for the checkbox property. Your OData service is returned data to you (using JSON notation for simplicity) like this:
data : [{
"COUNTRY_ID" : "USA",
"BRAND" : "Nike"
},{
"COUNTRY_ID" : "GER",
"BRAND" : "Adidas"
},{
"COUNTRY_ID" : "ITA",
"BRAND" : "Lotto"
}]
But you are using the returned model as if there is a third property in each object, named 'checked'. E.g.
data : [{
"COUNTRY_ID" : "USA",
"BRAND" : "Nike",
"checked" : false
},{
"COUNTRY_ID" : "GER",
"BRAND" : "Adidas",
"checked" : false
},{
"COUNTRY_ID" : "ITA",
"BRAND" : "Lotto",
"checked" : false
}]
If this property is not part of the model, then you effectively have nothing to bind your checkbox to. Because the property does not exist in the model, the check box column is not bound to anything. When the table is initialised to 10 rows, that is the number of checkbox controls you've created, no more. Once you begin paginating, the number rows never changes, but the pagination binds the next 10 rows of your OData dataset to the table rows and columns. Because the dataset doesn't contain the property 'checked' (my assumption), the column listing the checkboxes is not rebound to the model's data, thus the checked checkboxes never change.
I would suggest you do one of two things - update the OData service to include this additional property (checked), and bind the checkbox column to that property, or two, copy the model data to a new model, add the 'checked' property to each object in the collection, and then bind your table to this new model. Either way, you need to ensure that the model has a property to which you can bind the checkboxes.
This link to an editable Table control demonstrates the principal I'm referring to:
Editable Table control
In this example, the author is making a table editable by using the 'editable' property in each object in his collection. This property, which exists for every entry in the model's data, is bound to the TextField control in the table's second column.
template: new sap.ui.commons.TextField({
value: '{lname}',
editable: '{edit}' // Binding editable property of text field to 'edit' attribute of Model
}),
You'll need to do something very similar, but for the Checkbox, ensuring the model has a property to bind to.
Good luck.

Related

Datatables Columndef "target" tied to an Editor

I have this problem in which I have a Datatable with a "columnDefs" attribute that contains 4 column definitions in which each column defines a "target" that calls a column index (i.e "targets": 1). That is fine. However, I also want to create a datatable editor (bubble editor to be exact) that has a "fields" attribute containing "label" and "name". How can I tie up the "label" field of my editor to the datatable which only has "columnDefs" attribute without declaring a "column" attribute ? Thanks in advance.
$(document).ready(function() {
editor = new $.fn.dataTable.Editor( {
ajax: "../php/staff.php",
table: "#example",
fields: [ {
label: "First name:",
name: "first_name"

JQGrid: Pass JQGrid column value as a parameter to controller method specified in cellurl

I am looking for inline editing a JQGrid.
My JQGrid having column like :
colModel: [
{ name: 'Model_ID', index: 'model_id', width: 100, editable: false, hidden:
false },
{ name: 'Cust_Nm', index: 'cust_nm', width: 100, editable: false},
{ name: 'Model_Nm', index: 'model_nm', width: 140, editable: false, },
{ name: 'Client_Nm1', index: 'client_nm1', width: 120, editable: true},
{ name: 'Client_Nm2', index: 'client_nm2', width: 120, editable: true},
{ name: 'Client_Nm3', index: 'client_nm3', width: 120, editable: true},
{ name: 'Date', index: 'regi_date', width: 130, editable:false, search: false }
],
cellEdit: true,
cellurl: '#Url.Action("UpdateJQGrid", "Config")',
cellsubmit: "remote"
I want to pass value of 'Model_ID' to "UpdateJQGrid" Controller method. UpdateJQGrid is getting called when I edit one cell and move the focus to other cell inside the jggrid. I have created a View Model and passing that ViewModel to the Controller Method. But I am getting only the edited value through ViewModel object not other values of the selected row. If I can get only the value of Model_ID in Controller method my requirement will be solved.
Any help or hint is much appreciated.
It's very important to understand that the implementation of jqGrid require to assign id attribute to every row of the grid (to every <tr> element of the <table> with the main data). The documentation use rowid as the value of id attribute. If you use editing feature of jqGrid it's strictly recommended that you assign the value of id attribute based on the native value which will be get from the database (existing on the backend side). The rowid will be used in the most callbacks of jqGrid and will be post to the server during editing. Here you can read which information will be send to the server during cell editing.
If the values from Model_ID (or model_id) column are unique and the values come from the database than I would recommend you to use the value as the rowid. To inform jqGrid to use the value you can either specify the corresponding value of id property of jsonReader (or xmlReader). The value of id property depends on the exact format of the data returned from the server, which you use to fill the grid. Another way will be to specify key: true property in Model_ID (model_id) column. After the changes you will see that jqGrid will send the value from Model_ID (model_id) column to the server during cell editing. The value will be send as id=rowid (as id parameter). You can change the name of the parameter by usage prmNames: {id: "Model_ID"}, for example, which changes id=rowid to Model_ID=rowid.
One more remark. I recommend you don't use index property if it is not really required. If you miss the property then the value of name property will be used instead. The usage of different values for name and index properties is the origin of many errors and makes impossible to use client side sorting, paging and filtering/searching.

Grouping WSAPI data store by Parent Name

I am creating a rallygrid component and would like to have the grid items grouped by their parent's Name attribute (bonus if I could also display the ID of the parent). I added the groupBy:'Parent' configuration to the storeConfig of the grid and was surprised that no results were returned. I also tried using groupBy:'Parent.Name' but still nothing.
I know this is possible with other fields such as Owner, but I'm at a loss as to why the Parent wouldn't be usable as well. Is this a bug, or am I setting the config up incorrectly?
Thanks
Change the storeConfig to keep the records from trying to update after being grouped:
storeConfig : {
remoteSort : false,
remoteGroup : false,
remoteFilter : false,
}
Add a listener to the load event which assigns a root level property to the record and groups by that record value. (For some reason store.group('Parent.Name'); doesn't work.)
load: function(store) {
store.each(function(record) {
record.set('ParentName', record.get('Parent') && record.get('Parent').Name || '-- Unparented --');
});
store.group('ParentName');
}
I thought it was a bug with the SDK too, but per WS API documentation, Parent, unlike Owner, or Feature is not sortable.
So when I use groupField: 'Parent' the grid is empty, and response showed error:
Ext.data.JsonP.callback6({"QueryResult": {..., "Errors": ["Cannot sort using attribute Parent"]
It is trying to sort by Parent, but Parent attribute is not sortable. So the SDK ran into a WS API limitation.
On a side note, I did not use groupBy, instead I used groupField on the store (in this example I grouped by Kanban field) :
var myStore = Ext.create('Rally.data.WsapiDataStore',{
model: 'UserStory',
groupField: 'c_MyKB',
//...
});
And then used features: [{ftype:'grouping'}] in the grid.
this._myGrid = Ext.create('Ext.grid.Panel', {
store: myStore,
features: [{ftype:'grouping'}],
//...

dojo select field displayed value

I use the dijit.form.select with the grid editor like this:
editor({
label: 'status',
field: 'status_name',
editorArgs: {
style: "width:75px;",
options: task_status
},
className: 'style8'
}, Select, "dblclick"),
when I open the select field and choose an option from the list, this returns the 'value' of selected option not the name of it.
how to get the value instead of the value?
Check the objects in your options list.
Each object should have a label and value property. The label is what will be displayed when selected.

Removing duplicates from a Dojo FilteringSelect

I'm trying to remove duplicates from a Dojo FilteringSelect without changing the contents of the attached itemFileReadStore data store. I can't seem to find any information on how this is done, if it is indeed possible.
I'm thinking I may have to extend the FilteringSelect Dijit and provide the functionality myself but I'm hoping to not have to.
The reason I'm trying to remove duplicates with the FilteringSelect and not the data store is because I'm using the same data store with three instances of the FitleringSelect, each displaying different values from each row of the store.
If your store FilteringSelect searchAttr is the same as in your dataStore "identifier", you will see a unique set of values in the dropdown.
For example, if you change the identifier from myStore to "color", your dropdown will show only red, orange and yellow instead of having a duplicate yellow.
That is why, if you use this store definition in your FilteringSelect and set the searchAttr to "Fruit" you will see only two values; orange and apple
var myStore = new dojo.data.ItemFileReadStore({
url: 'data.json'
});
<div dojoType="dijit.form.ComboBox" store="myStore" id="fsKeywords" searchAttr="name" onChange="filterGrid()"></div>
data.json file:
{
identifier: "Fruit",
label: "Name",
items: [
{
"Fruit":"orange",
"color":"red",
"size":"small"
},
{
"Fruit":"orange",
"color":"orange",
"size":"big"
},
{
"Fruit":"orange",
"color":"yellow",
"size":"small"
},
{
"Fruit":"apple",
"color":"yellow",
"size":"small"
}
]}
I wonder if there is a way to change the store identifier programatically