I have a question concerning pagination in Symfony 1. I have the code below which give me the paginated records of the Offer table. How could I change the order from asc to desc?
protected function getPager() {
$pager = new sfDoctrinePager('Offer', 1000);
$pager->setQuery($this->buildQuery());
$pager->setPage($this->getPage());
$pager->init();
return $pager;
}
It's not the pager having to add the order but the query. So you can create a query manually (where you set also the ordering needed) and pass it to $pager->setQuery().
if i may add a solution.
use jQuery + datatables.net. its neat and fast. Message me for sample code.
ejaymejr#gmail.com
Preview of the Datatable i created.
https://imgur.com/a/a9w22
Related
We are looking for information on how to add content to an Editable Image programatically (with the Kentico C# API). Essentially, the equivalent of this Editable Region article for an Editable Image.
Any suggestions?
Thanks,
Victor
References:
CMSEditableImage Docs
Devnet Update EditableRegion Programatically
CMSEditableImage Class
You Sure Can
Each individual editable cms page control is stored in the document's DocumentContent field and can be accessed using an indexer field. For example:
TreeNode document = DocumentContext.CurrentDocument;
string editableImageControlId = "EditableImage1";
// get the field value
string editableImageContent = document.DocumentContent.EditableRegions[editableImageControlId];
// set it to something new
document.DocumentContent.EditableRegions[editableImageControlId] = newValue;
HOWEVER
If you look at the DocumentContent field in CMS_Document in the database you'll notice that all of the content is XML. That's because each control is serialized into XML and then nested inside this field. Thus, in this case, the value of the editableImageContent variable is an XML string:
<image>
<property name="imagepath">
~/Folder/ImageName.png
</property>
</image>
I wouldn't recommend trying to modify this directly since there's no telling if Kentico would ever change this code, or the individual control would ever change its serialization output.
But if you really must
You've got a couple of options:
1. Per #josh, you could create a new control that wraps the existing one and do some method override magic so that the control continues to do the serialization on your behalf and you just modify it after the fact. However this requires that the control is currently loading.
2. You could just hard code the beast and deal with it if it ever changes (which it likely will). Try:
// get the node from wherever you need to get the node
TreeNode document = DocumentHelper.GetDocuments().TopN(1).FirstObject;
var relativeMediaFilePath = "~/NewImage.png";
var xmlImage = string.Format("<image><property name=\"imagepath\">{0}</property></image>", relativeMediaFilePath);
var cmsControlId = "editableImage1";
if (document.DocumentContent.EditableRegions.ContainsKey(cmsControlId)) {
document.DocumentContent.EditableRegions[cmsControlId] = xmlImage;
}
else {
document.DocumentContent.EditableRegions.Add(cmsControlId, xmlImage);
}
// a little hack to get this field to be indicated as updated
document.SetValue("DocumentContent", document.DocumentContent.GetContentXml());
document.Update(true);
You could clone the editableimage webpart and then work in the prerender or change the override for the GetContent() method and add your own part of the string or do a string replace and add your code.
What is that you want to add to an Editable Image? - image path?! Not sure why you'd do that, but I'd take another direction: I'd add a field to a page type, which makes it much easier to work with through API. Having this field set up with API is should be quite easy to get it on the page... e.g. place editable image and use a macro to get field value.
Use
node.DocumentContent.EditableWebParts
and
node.DocumentContent.EditableRegions
collections to programmatically update editable content.
The best code example can be spotted at \CMS\CMSModules\Content\CMSDesk\Properties\Advanced\EditableContent\Main.aspx.cs
It's the dialog under Pages->General->Advanced->Edit regions & web parts.
There is a viewPanel having a column with showCheckbox="true".
Is it possible to restrict the users to select only one row/document ( and not multiple rows/docs. ) listed by the viewPanel?
Not in a View Panel. The View Panel is designed to offer a quick, simple approach with restricted functionality.
An alternative (possibly better) approach may be to have another column with a link or image that triggers whatever functionality you need. That will allow users to trigger functionality with a single click rather than two. The View Panel allows you to place controls in columns instead of just mapping to a column in the underlying view.
Alternatively, you could add a checkbox manually to a column, map to a scoped variable, and check/uncheck programmatically.
Paul's probably right on. My alternative for you is to use a repeat control. You can make it look however you want. Including a view control.
I have an example of this in this NotesIn9 show: http://notesin9.com/index.php/2011/07/11/notesin9-ee-009-using-java-hashmaps-and-treemaps-with-xpages/
Now in my example I did multiple values. But if instead of a HashMap or ArrayList if you kept your "selected" document id in a single value field like just a scoped variable.. then you'd get what you want. One document at a time.
I agree with Paul Stephans (also upvoted his answer because I think it would be the Nest solution) but if you insist on adding such a functionality to your viewPanel you can do this by adding a client side script to prevent the user from selecting more then one element:
First add the styleClass="rowCB" to your checkbox row and insert this code to your xpage:
<xp:scriptBlock>
<xp:this.value><![CDATA[dojo.ready(function(){
dojo.query('.rowCB>input').connect("onclick", function(evt){
var target = evt.target.id;
if(!window.crrCheckedElement){
window.crrCheckedElement = evt.target.id;
}else if(window.crrCheckedElement != target){
alert("You can select only one item!");
evt.target.checked = false;
}else if(window.crrCheckedElement == target){
window.crrCheckedElement = "";
}
})
});]]></xp:this.value>
</xp:scriptBlock>
Maby the code needs some improvement but this should be your way to go.
though maybe not the best solution, here is one possibility.
function deselectOtherDocs(viewName, currentDocId) {
var viewPanel:com.ibm.xsp.component.xp.XspViewPanel = getComponent(viewName);
var selectedIds = viewPanel.getSelectedIds();
for(var i=0; i<selectedIds.length; ++i){
if(selectedIds[i]!=currentDocId){viewPanel._xspSetIdUnchecked(selectedIds[i])}
return;
}
fire this off when a doc is checked and pass the view control name and the current doc's unid.
pardon any typos. I am writing from my phone.
edit: if you don't have to use a view control, then David Leedy's suggestion is the way to go. store the selected unid in a scope variable and let that determine which repeat row's box is selected. you might also consider using a radio button instead of a checkbox, since the former is understood as a single selector by users.
I used the tutorial on link TUTORIAL LINK
Now I want to perform the search operation on tableview to search for table row contents to match the query.
So is there any way to to search for items in tableview.
Something I found in c# was the LINQ query which search in the list for condition.
Is there something similar in javafx.
Seems, there is nothing similar. You can file a RFE, or a Tweak, in JavaFX-2 jira, if you want to have such functionality (if it doesn't exist yet).
Or, if you know, how should it look like, you can talk to author of TableView, and implement it by yourself, and push according patch in an open javafx.
Practically, you can do a search over a collection of content of TableView, and apply value factory of each column for according value, and check, if it returns an appropriate value/content.
I saw a project like this once.
Maybe this is what your looking for: Advanced TableView
Sadly i have no idea how they implemented it.
EDIT The page i linked to states that you should go to the following page: TiwulFX
this is search method, where data is your list ,
private boolean search(String a ){
int i=0;
do{
if(data.get(i).getNom().equals(a) )
{
return true;
}
i++;
}while(data.size()>i);
return false;}
1) Get your TableView object
2) Call getItems() method on it
3) Call get() method the parameter for this method is the index of your object
TableView<String> tableView = new TableView<>();Now, suppose that we've already filled tableView with Products objects
You can reach to every object this way
tableView.getItems().get(0)
This will return the first object you added to tableView
I Hope This Helps ^_^
I have a button, In Button on click event has set of codes,
I want to update two particular element using Server side Javascript.
But these are in different tags...
I want to update an element using SSJS code.
I am using Lotu notes 8.5.2.
Please check out this blog by Tim Tripcony, It will show you how to update two panels via partial refresh.
http://www.timtripcony.com/blog.nsf/d6plinks/TTRY-84B6VP
basically the code for two refreshes looks like below.
XSP.partialRefreshGet("#{id:div3}", {
onComplete: function() {
XSP.partialRefreshGet("#{id:div4}");
}
});
You should update the datasource for the components and dont try to 'refresh' them. If you realy want to update their values you use
getComponent(x).setValue();
Another approach would be to just use the partialrefreshget()..
I am using rich:dataTable with rich:dataTableScroller. And I don't want load all my data from DB when initialize table, because I have very many records. I want that that rich:dataTableScroller show me real page count but load page only when I switch on in. I find some solution here
But I want use rich:dataTable andrich:dataTableScroller, and don't write my own components. Have somebody some ideas ?
You should create a custom org.richfaces.model.DataProvider, and in getItemsByRange you should fetch the limited data.
You should then construct an ExtendedTableDataModel passing your custom DataProvider, and use this model in your <rich:dataTable> - value="#{myBean.myExtendedDataModel}"
You can create your own "PagedDataModel", which actually returns only the data that will be shown in the page you are seeing.
I have found an example for this here.
You can write your own datamodel as child of richfaces ExtendedDataModel, which has method:
protected List<T> loadData(int offset, int limit, List<Order> orders)