Search Results

Search found 340 results on 14 pages for 'sortable'.

Page 12/14 | < Previous Page | 8 9 10 11 12 13 14  | Next Page >

  • Jqgrid: navigation based on the selected row

    - by bsreekanth
    Hello, I was trying to enable navigation based on a selected row. So, the user select a row from jQgrid, and when press the show (is there a show button for the grid, I saw edit, add etc), it needs to go to a new page based on the url (part of the row). $(document).ready(function () { function getLink() { // var rowid = $("#customer_list").jqGrid('getGridParam', 'selrow'); var rowid = $("#customer_list").getGridParam('selrow'); var MyCellData = $("#customer_list").jqGrid('getCell', rowid, 'dataUrl'); return MyCellData; } $("#customer_list").jqGrid({ url:'mytestList', editurl:'jq_edit_test', datatype: "json", colNames:['Call Id','Title','dataUrl'], colModel:[ {name:'callId', width:80, search:false }, {name:'title', width:200, sortable:false }, {name:'dataUrl',hidden:true} ], rowNum:10, sortname:'lastUpdated', sortorder: 'desc', pager:'#customer_list_pager', viewrecords: true, gridview: true }).navGrid('#customer_list_pager', {add:true,edit:true,del:false,search:true,refresh:true}, {closeAfterEdit:true, afterSubmit:afterSubmitEvent }, // edit options {addCaption:'Create New something', afterSubmit:afterSubmitEvent, savekey:[true,13]}, // add options {afterSubmit:afterSubmitEvent} // delete options ); $("#customer_list").jqGrid('filterToolbar'); }); so, the url is passed for each row as dataUrl. I'm trying to read it and set to the button. Whn debug through firebug, the rowid was 223 (there were only 12 rows in the grid), and the cell value is empty. Currently the button is kept outside the grid, but it may better to be it part of the vavGrid thanks.

    Read the article

  • How can I sort a DataGridTemplateColumn on a WPF Toolkit DataGrid?

    - by Kilhoffer
    I have a WPF Toolkit DataGrid with one DataGridTemplateColumn. I've specified in a grid attribute that I wish all columns to be sortable, but the DataGridTemplateColumn won't allow it. All other columns do allow sorting. I've even tried explicitly setting CanUserSort to true for that column, but no luck. Is it even possible to sort a template column? I've provided a custom sorter that works for all columns, but the header won't allow a sort click. <Controls:DataGrid ItemsSource="{Binding Events}" AutoGenerateColumns="False" CanUserSortColumns="True" CanUserReorderColumns="False" Sorting="DataGrid_Sorting" x:Name="EventsGrid"> <Controls:DataGrid.Columns> <Controls:DataGridTemplateColumn Header="Type" Width="42" CanUserResize="False"> <Controls:DataGridTemplateColumn.CellTemplate> <DataTemplate> <Image Source="{Binding EventTypeImage, Mode=OneWay}" HorizontalAlignment="Center" Width="16"/> </DataTemplate> </Controls:DataGridTemplateColumn.CellTemplate> </Controls:DataGridTemplateColumn> <Controls:DataGridTextColumn Header="Source" Binding="{Binding Source, Mode=OneWay}" /> <Controls:DataGridTextColumn Header="Details" MinWidth="175" Binding="{Binding Details, Mode=OneWay}" /> <Controls:DataGridTextColumn Header="Timestamp" MinWidth="175" Binding="{Binding Timestamp, Mode=OneWay}" IsReadOnly="True"/> </Controls:DataGrid.Columns> </Controls:DataGrid>

    Read the article

  • JQGrid: Dropdown for selecting items from a foreign table - DataValueField vs DataTextField

    - by Herb Caudill
    Suppose Items and ItemTypes have numeric primary keys ItemID and ItemTypeID. Each Item is assigned an ItemType. I have a JQGrid to edit Items. When not in edit mode, I would like to see the name of the ItemType, not the ItemTypeID: TYPE | TITLE -----------+-------------------- Category A | Item 1 Category A | Item 2 Category B | Item 3 Category B | Item 4 In edit mode, I want to see a dropdown that displays the ItemType text, but that returns the ItemTypeID to the server. Here's what I have so far (using the ASP.NET wrapper for JQGrid): <trirand:jqgrid id="Grid1" runat="server" ... > <columns> <trirand:jqgridcolumn datafield="ItemID" editable="false" visible="false" width="50" primarykey="true" /> <trirand:jqgridcolumn datafield="ItemTypeID" editable="true" edittype="DropDown" editorcontrolid="ItemTypes" /> <trirand:jqgridcolumn datafield="Title" editable="true" sortable="true" /> ... </columns> </trirand:jqgrid> <asp:sqldatasource runat="server" id="ItemTypesDatasource" connectionstring="<%$ ConnectionStrings:Main %>" selectcommand="Select ItemTypeID,Title from ItemTypes order by Title" /> <asp:dropdownlist runat="server" id="ItemTypes" datasourceid="ItemTypesDatasource" datavaluefield="ItemTypeID" datatextfield="Title" /> The problem is that when not in edit mode, it displays the numeric ItemTypeID, rather than the text labels: TYPE | TITLE -----------+-------------------- 100123 | Item 1 100123 | Item 2 100124 | Item 3 100124 | Item 4 Is there any way to have JQGrid respect the distinction between DataValueField and DataTextField? (Either using the jQuery API or the ASP.NET plugin.)

    Read the article

  • Extjs Dynamic Grid

    - by rkenshin
    Hi, I'm trying to create a dynamic grid using Extjs. The grid is built and displayed when a click event is fired then an ajax request is sent to the server to fetch the columns, records and records definition a.k.a Store Fields. Each node could have different grid structure and that depends on the level of the node in the tree. The only way i came up with so far is function showGrid(response, request) { var jsonData = Ext.util.JSON.decode(response.responseText); var grid = Ext.getCmp('contentGrid'+request.params.owner); if(grid) { grid.destroy(); } var store = new Ext.data.ArrayStore({ id : 'arrayStore', fields : jsonData.recordFields, autoDestroy : true }); grid = new Ext.grid.GridPanel({ defaults: {sortable:true}, id:'contentGrid'+request.params.owner, store: store, columns: jsonData.columns, //width:540, //height:200, loadMask: true }); store.loadData(jsonData.records); if(Ext.getCmp('tab-'+request.params.owner)) { Ext.getCmp('tab-'+request.params.owner).show(); } else { grid.render('grid-div'); Ext.getCmp('card-tabs-panel').add({ id:'tab-'+request.params.owner, title: request.params.text, iconCls:'silk-tab', html:Ext.getDom('grid-div').innerHTML, closable:true }).show(); } } The function above is called when a click event is fired 'click': function(node) { Ext.Ajax.request({ url: 'showCtn', success: function(response, request) { alert('Success'); showGrid(response,request); }, failure: function(results, request) { alert('Error'); }, params: Ext.urlDecode(node.attributes.options); } The problem i'm getting with this code is that a new grid is displayed each time the showGrid function is called. The end user sees the old grids and the new one. To mitigate this problem, I tried destroying the grid and also removing the grid element on each request, and that seems to solve the problem only that records never get displayed this time. if(grid) { grid.destroy(true); } The behavior i'm looking for is to display the result of a grid within a tab and if that tab exists replaced the old grid. Any help is appreciated. Thank you

    Read the article

  • Entity Framework 4.0 Databinding with sorting not working

    - by Mike Gates
    I want to do something that I thought would be very simple. I want to bind a generated Entity Framework EntityCollection to a WPF DataGrid. I also want this grid to be sortable. I have tried all kinds of things to make this happen, including using a CollectionViewSource. However, nothing seems to work. Using a normal CollectionViewSource around the EntityCollection gives me: 'System.Windows.Data.BindingListCollectionView' view does not support sorting. Ok...strange. I would have thought this would work. Next on the CollectionViewSource, I try setting: CollectionViewType="ListCollectionView" Great, sorting now works. But wait, I can't add or remove entities using the grid now, presumably because ListCollectionView doesn't support this with an entity framework context. So, I guess I need to capture events coming out of the datagrid in order to add or remove entities manually from my context. Now I can't find an event to capture to detect an add...! Why is this so hard? This should be the standard "demo" case that Microsoft should have designed around. Any ideas?

    Read the article

  • ExtJS: Autoscroll vertical FormPanels added to panel

    - by Sarge
    Hi All, I'm writing an app where I have a BorderLayout for the entire page. In the south part I have a Panel to which I add FormPanels. I would like to be able to scroll that Panel so I can scroll through the FormPanels. So far, nothing I've found from searches has helped. I don't quite understand what ExtJS requires in terms of the combination of LayoutManagers, setting the size and setting AutoScroll. Any partial tips will be gratefully followed up. A code snippet: createTrailJunctionPanel = function(trailJunction) { var trailJunctionPanel = new Ext.form.FormPanel({ labelWidth: 75, width: 350, defaultType: 'textfield', items: [{ fieldLabel: 'Junction Name', name: 'junction-name' }], autoScroll:true, //anchor: '100% 100%', height: 100 }); matchedTrailJunctionsPanel.add(trailJunctionPanel); if(trailJunction.publicTrailSegments.length == 0) { matchedTrailJunctionsPanel.add(new Ext.form.Label({text: 'No public trails matched'})); } else { var grid = new Ext.grid.GridPanel({ store: mapMatchObjectStore, columns: [ {id:'publicTrailSegment',header: 'Trail', width: 160, sortable: true, dataIndex: 'publicTrailSegment'} ], stripeRows: true, autoExpandColumn: 'publicTrailSegment', height: 350, width: 600, title: 'Matched Trail Junctions' }); matchedTrailJunctionsPanel.add(grid); } matchedTrailJunctionsPanel.doLayout(); } matchedTrailJunctionsPanel = new Ext.Panel({ title: "Matched Trail Junctions2", id: "matched-trail-junctions", autoScroll:true //layout: 'anchor' });

    Read the article

  • Creating a drop-down row in displaytag

    - by bphilipnyc
    I am currently using displaytag for tabular data, but would like to create a "kayak.com-like" interface where when a user clicks a row, the user is shown more details about the particular row without a page refresh. I tried using a decorator to return javascript that would do this. The javascript is executed, but it is only reflected in the column where it was rendered. I am looking to create a new row with the data. e.g.: public class CustomDecorator extends TableDecorator { public String getDetailsRow() { MyObject object = (MyObject)this.getCurrentRowObject(); return "<a onClick=\"myjsfunction(object.getId()); return true\">Details</a>"; } } ...and in the JSP I would have a detailsRow property nested between the display:table tags: <display:column property="detailsRow" sortable="false" /> Any tips on how to create a new row? The solution may be in the way that the javascript is written - I'm not an expert with Javascript, so any tips would be appreciated. Is there a better way to do this with displaytag? I don't know of any explicit integration that displaytag has with javascript (like an "onclick" parameter) either. This is my first question on stackoverflow, btw - so please let me know whether you need more detail.

    Read the article

  • Why is my jQuery jEditable, edit-in-place callback not working?

    - by unknowndomain
    I am using a jQuery jEditable edit-in-place field but when the JSON function returns and I try to return a value from my edit-in-place callback all I get is a flash of You can see this here... http://clareshilland.unknowndomain.co.uk/ Hit Ctrl+L to login... Username: stackoverflow Password: jquery Although you can see the script in /script.js here is the main code exerpt... $('#menu li a').editable(edit_menu_item, { cssclass: 'editable' }); Here is the callback: function edit_menu_item(value, settings) { $.ajax({ type : "POST", cache : false, url : 'ajax/menu/edit-category.php', dataType: 'json', data : { 'id': this.id, 'value': value }, success : function(data) { if (data.status == 'ok') { alert('ok'); return data.title; } else { alert('n/ok'); return this.revert; } }}); } The JSON code is here: ajax/menu.edit-category.php The edit-in-place is is on the menu which also has a jQuery sortable on it. Single click to edit. Enter to save, and it stores the data but does not update it on the edit-in-place field. Please help stackoverflow, I have been working on this for a mega age. Thanks in advance!

    Read the article

  • ASP.Net: Adding client side onClick to a HyperlinkField in GridView

    - by Nir
    I have an existing GridView which contains the field "partner name". It is sortable by partner name. Now I need to change the Partner Name field and in some condition make it clickable and alert() something. The existing code is: <asp:GridView ID="gridViewAdjustments" runat="server" AutoGenerateColumns="false" AllowSorting="True" OnSorting="gridView_Sorting" OnRowDataBound="OnRowDataBoundAdjustments" EnableViewState="true"> <asp:BoundField DataField="PartnerName" HeaderText="Name" SortExpression="PartnerName"/> I've added the column: <asp:hyperlinkfield datatextfield="PartnerName" SortExpression="PartnerName" headertext="Name" ItemStyle-CssClass="text2"/> which enables me to control the CSS and sort. However, I can't find how to add a client side javascript function to it. I found that adding : <asp:TemplateField HeaderText="Edit"> <ItemTemplate> <a id="lnk" runat="server">Edit</a> enable me to access "lnk" by id and add to its attributes. However, I lose the Sort ability. What's the correct solution in this case? Thanks.

    Read the article

  • Question: Richfaces tabPanel - using the same page for the different tabs changing the content dinam

    - by user280320
    I am using Seam 2.1.2 and RichFaces 3.3.2.SR1. <a4j:form> <rich:tabPanel switchType="ajax"> <rich:tab label="TAB 1" actionListener="#{outControl.tab1}" immediate="true"> <ui:include src="/pages/agenda/TabContain.xhtml" /> </rich:tab> <rich:tab label="TAB 2" actionListener="#{outControl.tab2}"> <ui:include src="/pages/agenda/TabContain.xhtml" /> </rich:tab> ... TabContain.xhtml: <rich:extendedDataTable value="#{manBean.seDataModel}" var="out" id="bc_table" sortMode="#{manBean.sortMode}" selectionMode="#{manBean.selectionMode}" tableState="#{manBean.tableState}" selection="#{manBean.selection}" rowKeyVar="rkvar"> <rich:column sortable="false" id="bc_col_0"> ... The content of extendedDataTable should be dependent of the tab selected. My first approach was to set an actionListener in the tabs and change the manBean within that action. After that actionListener even if I can see in the logs that the manBean has changed, this is not reflected in the page in the browser. It's like not refreshing. I tried setting a rerender in the rich:tab but that's also not doing it. Any idea? Also happy about other approaches, this might be not the best one.

    Read the article

  • kendo ui filtering the grid table, need some idea

    - by cool_spirit
    I want to filter the table by last name, but cant work, here is my code in controller public JsonResult Filtering() { HealthContext rc = new HealthContext(); var last = rc.Profiles.Select(lastt => new SelectListItem { Text = lastt.LastName, Value = lastt.Id.ToString() }).ToList(); return Json(last.ToList(), JsonRequestBehavior.AllowGet); } in view <script type="text/x-kendo-template" id="template"> <div class="toolbar"> <label class="category-label" for="Last name"> by last name:</label> <input type="search" id="LastName" style="width: 230px"></input> </div> </script> and also <script> $(document).ready(function() { $("#grid").kendoGrid({ dataSource: { transport: { read: { url: "/Profiles/GetJsonData", dataType: "json" } }, pageSize: 10, }, toolbar: kendo.template($("#template").html()), height: 250, filterable: true, sortable: true, pageable: true, defaultSorting: 'LastName ASC', columns: [{ field: "Id", filterable: false }, { field: "FirstName", title: "First Name", width: 100, }, { field: "LastName", title: "Last Name", width: 200 }, { field: "Gender", title: "Gender" } ] }); var dropDown = grid.find("#LastName").kendoDropDownList({ dataTextField: "LastName", dataValueField: "Id", autoBind: false, optionLabel: "All", dataSource: { severFiltering: true, transport: { read: { url: "/Profiles/Filtering", dataType: "json" } }, }, change: function() { var value = this.value(); if (value) { grid.data("kendoGrid").dataSource.filter({ field: "Id", operator: "eq", value: parseInt(value) }); } else { grid.data("kendoGrid").dataSource.filter({}); } } }); }); </script> so the problem is the drop down list is not show up as well as the value/ data, any idea guys?

    Read the article

  • Using jQuery.UI CSS Framework for DIV Styling

    - by Gordon
    Hi folks, a Project I am currently working on uses the jQuery UI framework for some of its widgets. To provide the user with a global look and feel I would like to use the framework also for its css stuff. I am implementing at the moment a dashboard like homepage, where the user can see an overall status of its data. This dashboard is build of some divs that should be aligned into a grid layout. I try to style the divs like follows <div class="ui-widget"> <div class="ui-widget-header">Box Header</div> <div class="ui-widget-content"> Content of the Box </div> </div> Later I would like to implement some draggable-and-sortable functionality. The Problem I am facing right now is that the boxes aren't properly aligned. Does anyone has a hint on using jQuery.UI for that kind of css work? I was studing the CSS framework documentation on jqueryui.com but there aren't that much information. best regards, Gordon

    Read the article

  • jqGrid - edit function never getting called

    - by dcp
    I'm having a problem with JQGrid using ASP.NET MVC. I'm trying to follow this example (after you go to that link, over on the left side of the page please click Live Data Manipulation, then Edit Row), but my edit function is never getting called (i.e. it's never getting into the $("#bedata").click(function(). Does anyone know what could be the problem? <script type="text/javascript"> var lastsel2; jQuery(document).ready(function() { jQuery("#editgrid").jqGrid({ url: '/Home/GetMovieData/', datatype: 'json', mtype: 'GET', colNames: ['id', 'Movie Name', 'Directed By', 'Release Date', 'IMDB Rating', 'Plot', 'ImageURL'], colModel: [ { name: 'id', index: 'Id', width: 55, sortable: false, hidden: true, editable: false, editoptions: { readonly: true, size: 10} }, { name: 'Movie Name', index: 'Name', width: 250, editable: true, editoptions: { size: 10} }, { name: 'Directed By', index: 'Director', width: 250, align: 'right', editable: true, editoptions: { size: 10} }, { name: 'Release Date', index: 'ReleaseDate', width: 100, align: 'right', editable: true, editoptions: { size: 10} }, { name: 'IMDB Rating', index: 'IMDBUserRating', width: 100, align: 'right', editable: true, editoptions: { size: 10} }, { name: 'Plot', index: 'Plot', width: 150, hidden: false, editable: true, editoptions: { size: 30} }, { name: 'ImageURL', index: 'ImageURL', width: 55, hidden: true, editable: false, editoptions: { readonly: true, size: 10} } ], pager: jQuery('#pager'), rowNum: 5, rowList: [5, 10, 20], sortname: 'id', sortorder: "desc", height: '100%', width: '100%', viewrecords: true, imgpath: '/Content/jqGridCss/redmond/images', caption: 'Movies from 2008', editurl: '/Home/EditMovieData/', caption: 'Movie List' }); }); $("#bedata").click(function() { var gr = jQuery("#editgrid").jqGrid('getGridParam', 'selrow'); if (gr != null) jQuery("#editgrid").jqGrid('editGridRow', gr, { height: 280, reloadAfterSubmit: false }); else alert("Hey dork, please select a row"); }); </script> The relevant HTML is here: <table id="editgrid"> </table> <div id="pager" style="text-align: center;"> </div> <input type="button" id="bedata" value="Edit Selected" />

    Read the article

  • Jquery with multi level json data array

    - by coder
    var data = [{"Address":{"Address":"4 Selby Road\nHowden","AddressId":"1414449","AddressLine1":"4 Selby Road","AddressLine2":"Howden","ContactId":"14248844","County":"North Humberside","Country":"UK","Postcode":"DN14 7JW","Town":"GOOLE","FullAddress":"4 Selby Road\nHowden\r\nGOOLE\r\nNorth Humberside\r\nDN14 7JW\r\nUnited Kingdom"},"ContactId":14248844,"Title":"Mrs","FirstName":"","Surname":"Neild","FullName":" Neild","PostCode":"DN14 7JW"},{"Address":{"Address":"466 Manchester Road\nBlackrod","AddressId":"1669615","AddressLine1":"466 Manchester Road","AddressLine2":"Blackrod","ContactId":"16721687","County":"","Country":"UK","Postcode":"BL6 5SU","Town":"BOLTON","FullAddress":"466 Manchester Road\nBlackrod\r\nBOLTON\r\nBL6 5SU\r\nUnited Kingdom"},"ContactId":16721687,"Title":"Miss","FirstName":"Andrea","Surname":"Neild","FullName":"Andrea Neild","PostCode":"BL6 5SU"},{"Address":{"Address":"5 Prospect Vale\nHeald Green","AddressId":"2127294","AddressLine1":"5 Prospect Vale","AddressLine2":"Heald Green","ContactId":"21178752","County":"Cheshire","Country":"UK","Postcode":"SK8 3RJ","Town":"CHEADLE","FullAddress":"5 Prospect Vale\nHeald Green\r\nCHEADLE\r\nCheshire\r\nSK8 3RJ\r\nUnited Kingdom"},"ContactId":21178752,"Title":"Mrs","FirstName":"","Surname":"Neild","FullName":" Neild","PostCode":"SK8 3RJ"}]; I'm tring to retrieve above json fommated data in jquery as below: var source = { localdata: data, sort: customsortfunc, datafields: [ { name: 'Surname', type: 'string' }, { name: 'FirstName', type: 'string' }, { name: 'Title', type: 'string' }, { name: 'Address.Address', type: 'string' } ], datatype: "array" }; var dataAdapter = new $.jqx.dataAdapter(source); $("#jqxgrid").jqxGrid( { width: 670, source: dataAdapter, theme: theme, sortable: true, pageable: true, autoheight: true, ready: function () { //$("#jqxgrid").jqxGrid('sortby', 'firstname', 'asc'); $("#jqxgrid").jqxGrid('sortby', 'FirstName', 'asc'); }, columns: [ { text: 'Title', datafield: 'Title', width: 100 }, { text: 'First Name', datafield: 'FirstName', width: 100 }, { text: 'Last Name', datafield: 'Surname', width: 100 }, { text: 'Address', datafield: 'Address.Address', width: 100 }, ] }); The only issue is there is no display for "Address.Adress". Can anyone advise me ?

    Read the article

  • What is the correct date format for a Date column in YUI DataTable ?

    - by giulio
    I have produced a data table. All the columns are sortable. It has a date in one column which I formatted dd/mm/yyyy hh:mm:ss . This is different from the default format as defined in the doco, but I should be able to define my own format for non-american formats. (See below) The DataTable class provides a set of built-in static functions to format certain well-known types of data. In your Column definition, if you set a Column's formatter to YAHOO.widget.DataTable.formatDate, that function will render data of type Date with the default syntax of "MM/DD/YYYY". If you would like to bypass a built-in formatter in favor of your own, you can point a Column's formatter to a custom function that you define. The table is generated from HTML Markup, so the data is held within "" tags. This gives me some more clues about compatible string dates for javascript: In general, the RecordSet expects to hold data in native JavaScript types. For instance, a date is expected to be a JavaScript Date instance, not a string like "4/26/2005" in order to sort properly. Converting data types as data comes into your RecordSet is enabled through the parser property in the fields array of your DataSource's responseSchema I suspect that the I'm missing something in the date format. So what is an acceptable string date for javascript, that Yui dataTable will recognise, given that I want format it as "dd/mm/yyyy hh:mm:ss" ?

    Read the article

  • create TableModel and populate jTable dynamically

    - by Julia
    Hi all! I want to store the results of reading lucene index into jTable, so that I can make it sortable by different columns. From index I am reading terms with different measures of their frequencies. Table columns are these : [string term][int absFrequency][int docFrequency][double invFrequency] So i in AbstractTableModel I can define column names, but i dont know how to get the Object[][]data with results from the following method: public static void FrequencyMap(Directory indexDir) throws Exception { List<Object>redoviLista = new ArrayList<Object>(); //final Map<String,TermRow> map = new TreeMap<String,TermRow>(); List<String>termList = new ArrayList<String>(); IndexReader iReader = IndexReader.open(indexDir); FilterIndexReader fReader = new FilterIndexReader(iReader); int numOfDocs = fReader.numDocs(); TermEnum terms = fReader.terms(); while (terms.next()){ Term term = terms.term(); String termText = term.text(); termList.add(termText); //Calculating the frequencies int df = iReader.docFreq(term); double idf = 0.0F; idf = Math.log10((double) numOfDocs / df); double tfidf = (df*idf); //Here comes important part Object oneTableRow[] = {termText, df, idf, tfidf}; redoviLista.add(jedanRed); // So i thaught to store them into list, and then later to copy into table, but didnt manage } iReader.close(); // So I need something like this, and i Neeed this array to be stored out of this method Object[][]data = new Object[redoviLista.size()][]; for (int i = 0; i < data.length; i++) { data[i][0] = redoviLista.get(i); } So I am kindda stuck here to proceed to implement AbstractTableModel and populate and display this table .... :/ Please help!

    Read the article

  • Bubble sort algorithm implementations (Haskell vs. C)

    - by kingping
    Hello. I have written 2 implementation of bubble sort algorithm in C and Haskell. Haskell implementation: module Main where main = do contents <- readFile "./data" print "Data loaded. Sorting.." let newcontents = bubblesort contents writeFile "./data_new_ghc" newcontents print "Sorting done" bubblesort list = sort list [] False rev = reverse -- separated. To see rev2 = reverse -- who calls the routine sort (x1:x2:xs) acc _ | x1 > x2 = sort (x1:xs) (x2:acc) True sort (x1:xs) acc flag = sort xs (x1:acc) flag sort [] acc True = sort (rev acc) [] False sort _ acc _ = rev2 acc I've compared these two implementations having run both on file with size of 20 KiB. C implementation took about a second, Haskell — about 1 min 10 sec. I have also profiled the Haskell application: Compile for profiling: C:\Temp ghc -prof -auto-all -O --make Main Profile: C:\Temp Main.exe +RTS -p and got these results. This is a pseudocode of the algorithm: procedure bubbleSort( A : list of sortable items ) defined as: do swapped := false for each i in 0 to length(A) - 2 inclusive do: if A[i] > A[i+1] then swap( A[i], A[i+1] ) swapped := true end if end for while swapped end procedure I wonder if it's possible to make Haskell implementation work faster without changing the algorithm (there's are actually a few tricks to make it work faster, but neither implementations have these optimizations)

    Read the article

  • Is it possible to search locally in jqGrid with treeGrid installed

    - by Nehu
    I am using jqGrid with treeGrid. I have added a filterToolbar. I would like to search locally instead of having a server call. The treegrid docs say that, "When we initialize the grid and the data is read, the datatype is automatically set to local." So, is it possible to implement local search with treeGrid. I tried the below configuration, but it is resulting in server calls. My Configuration is var grid = $("#grid").jqGrid({ treeGrid: true, treeGridModel: 'adjacency', ExpandColumn: 'businessAreaName', ExpandColClick : true, url:'agileProgramme/records.do', datatype: 'json', mtype: 'GET', colNames:['Id' , 'Business Area' , 'Investment' , 'Org' , 'Goal' ], colModel:[ /*00*/ {name:'agileProgrammeId',index:'agileProgrammeId', width:0, editable:false,hidden:true}, /*01*/ {name:'businessAreaName',index:'businessAreaName', width:160, editable:false}, /*02*/ {name:'programmeName',index:'programmeName', width:150, editable:false, classes:'link'}, /*03*/ {name:'org',index:'org', width:50, editable:false, classes:'orgHierarchy', sortable : false}, /*04*/ {name:'goal',index:'goal', width:70, editable:false} ], treeReader : { level_field: "level", parent_id_field: "parent", leaf_field: "leaf", expanded_field: "expanded" }, autowidth: true, height: 240, pager: '#pager', sortname: 'id', sortorder: "asc", toolbar:[true,"top"], caption:"TableGridDemo", emptyrecords: "Empty records", jsonReader : { root: "rows", page: "page", total: "total", records: "records", repeatitems: false, cell: "cell", id: "agileProgrammeId" } }); And to implement the search toolbar $('#grid').jqGrid('filterToolbar', {stringResult: true,searchOnEnter : true}); Would appreciate any help or any pointer on even if it is possible?

    Read the article

  • How to move list items from two lists (from different areas) to one specific list by clicking the li

    - by pschorr
    I've been having some issues setting up a list of items and moving them between each other. Is it possible to have multiple lists, with a link inside each item to move it to a specified list? i.e. List of actions with a plus next to the action, click the plus and move to a specified box? Furthermore, would it be possible to then load a lightbox (code would have to be inline I'd guess) from that page and move those names to the specific list as well? Example Images Thanks much! More broad view of my efforts so far... The initial issue being that I could not use listboxes due to their being rendered natively inside each individual browser. Through listboxes I was able to set this up, but with a trigger via the code below (found on stackoverflow). While it gave me partial functionality it did not get the target I was looking for. document.getElementById('moveTrigger').onclick = function() { var listTwo = document.getElementById('secondList'); var options = document.getElementById('firstList').getElementsByTagName('option'); while(options.length != 0) { listTwo.appendChild(options[0]); } } I then moved onto jqueryui's sortable and it's ability to connect multiple, and most important, style-able lists and to be dragged between each other. This works for the side by side tables, but it does not offer the usability I was looking for overall. So, I've come to where I'm unsure as to where to move forward. While I can get around PHP, I wouldn't know where to start with this one personally. I'm open to any and all options! Thanks much!

    Read the article

  • problem in accessing the path involving pagination using display tag

    - by sarah
    Hi All, I am using display tag for pagiantion and display of the data in table format the code is like <display:column title="Select" style="width: 90px;"> <input type="checkbox" name="optionSelected" value="<c:out value='${userList.loginName}'/>"/> </display:column> <display:column property="loginName" sortable="false" title="UserName" paramId="loginName" style="width: 150px; text-align:center" href="./editUser.do?method=editUser"/> the pagesize is one it will display one in a page and eidt page will be dispaly on click of login name,but when i go to the second page i get an error saying /views/editUser path not found.How exactly should i define the path ? the struts-config is like <!-- action for edit user --> <action path="/editUser" name="editUserForm" type="com.actions.UserManagementAction" parameter="method" input="/EditUser.jsp" scope="request"> <forward name="success" path="/views/EditUser.jsp" /> <forward name="failure" path="/views/failure.jsp" /> </action> Pleas tell me how should i define the access path for display tag as on click of edit link the first page works but not the second edit

    Read the article

  • drag and drop with jquery and php

    - by robertdd
    hy, i have a php array with the name of some images! i list all the images use this: $files = $_SESSION['files']; $imgid = $_POST['id']; if ($files){ foreach($files as $image ): print '<li id="liupimages">'."\n"; print '<a href="uploads/'.$image.'"><img id="'.$imgid.'" alt="'.$image.'" src="uploads/'.$image.'"></a>'."\n"; print "</li>\n"; endforeach; print <<<JS <script> $(".thumbs li a").click(function(){ var largePath = $(this).attr("href"); $('.thumbs li').removeClass('thumbac'); $(this).parent().addClass('thumbac'); $("#largeImg").hide() .attr({ src: largePath }) .load(function() { $(this).show(); }); return false; }); </script> JS; } i use jquery-ui to drag and drop images using this function: $(function() { $("#upimagesQueue").sortable({ opacity: 0.6, cursor: 'move', update: function() { //?? } }); }); after i drag and drop one image i want to be able to update the php array to! how to do this?

    Read the article

  • How to speed up the reading of innerHTML in IE8?

    - by Dennis Cheung
    I am using JQuery with the DataTable plugin, and now I have a big performnce issue on the following line. aLocalData[jInner] = nTds[j].innerHTML; // jquery.dataTables.js:2220 I have a ajax call, and result string in HTML format. I convert them into HTML nodes, and that part is ok. var $result = $('<div/>').html(result).find("*:first"); // simlar to $result=$(result) but much more faster in Fx Then I activate enable the result from a plain table to a sortable datatable. The speed is acceptable in Fx (around 4sec for 900 rows), but unacceptable in IE8 (more then 100 seconds). I check it deep using the buildin profiler, and found the above single line take all 99.9% of the time, how can I speed it up? anything I missed? nTrs = oSettings.nTable.getElementsByTagName('tbody')[0].childNodes; for ( i=0, iLen=nTrs.length ; i<iLen ; i++ ) { if ( nTrs[i].nodeName == "TR" ) { iThisIndex = oSettings.aoData.length; oSettings.aoData.push( { "nTr": nTrs[i], "_iId": oSettings.iNextId++, "_aData": [], "_anHidden": [], "_sRowStripe": '' } ); oSettings.aiDisplayMaster.push( iThisIndex ); aLocalData = oSettings.aoData[iThisIndex]._aData; nTds = nTrs[i].childNodes; jInner = 0; for ( j=0, jLen=nTds.length ; j<jLen ; j++ ) { if ( nTds[j].nodeName == "TD" ) { aLocalData[jInner] = nTds[j].innerHTML; // jquery.dataTables.js:2220 jInner++; } } } }

    Read the article

  • Thinking Sphinx with Rails - Delta indexing seems to work fine for one model but not for the other

    - by hack3r
    I have 2 models User and Discussion. I have defined the indices for the models as below: For the User model: define_index do indexes email indexes first_name indexes last_name, :sortable => true indexes groups(:name), :as => :group_names has "IF(email_confirmed = true and status = 'approved', true, false)", :as => :approved_user, :type => :boolean has "IF(email_confirmed = true and (status = 'approved' or status='blocked'), true, false)", :as => :approved_or_blocked_user, :type => :boolean has points, :type => :integer has created_at, :type => :datetime has user(:id) set_property :delta => true end For the Discussion model: define_index do indexes title indexes description indexes category(:title), :as => :category_title indexes tags(:title), :as => :tag_title has "IF(publish_to_blog = true AND sticky = false, true, false)", :as => :publish_to_main, :type => :boolean has created_at has updated_at, :type => :datetime has recent_activity_at, :type => :datetime has views_count, :type => :integer has featured has publish_to_blog has sticky set_property :delta => true end I have added a delta column to both tables as per the documentation. My problem is that delta indexing works only for the Discussion model and not for the User model. For ex: When I update the 'title' of a discussion, I can see the thinking sphinx is rotating the indices etc. (as is evident from the logs). But when I update the 'first_name' or the 'last_name' of a user, nothing happens. The User model also has a has_many :through association through a model called GroupsUser. I have setup a after_save on the GroupsUser as follows: def set_user_delta_flag user.delta = true user.save end Even this doesn't seem to trigger delta indexing on the User model. A similar setup for the Discussion model works perfectly! Can anyone tell me why this is happening?

    Read the article

  • bash: listing files in date order, with spaces in filenames

    - by Jason Judge
    I am starting with a file containing a list of hundreds of files (full paths) in a random order. I would like to list the details of the ten latest files in that list. This is my naive attempt: ls -las -t `cat list-of-files.txt` | head -10 That works, so long as none of the files have spaces in, but fails if they do as those files are split up at the spaces and treated as separate files. I have tried quoting the files in the original list-of-files file, but the here-document still splits the files up at the spaces in the filenames. The only way I can think of doing this, is to ls each file individually (using xargs perhaps) and create an intermediate file with the file listings and the date in a sortable order as the first field in each line, then sort that intermediate file. However, that feels a bit cumbersome and inefficient (hundreds of ls commands rather than one or two). But that may be the only way to do it? Is there any way to pass "ls" a list of files to process, where those files could contain spaces - it seems like it should be simple, but I'm stumped.

    Read the article

  • make array from a list of images with jquery

    - by robertdd
    i have a list of photos like this: <div class="upimage"> <ul id="upimagesQueue" class="thumbs ui-sortable"> <li id="upimagesKHGYUD"> <a href="uploads/0002.jpg"> <img src="uploads/0002.jpg" id="KHGYUD"> </a> </li> <li id="upimagesNCEEKI"> <a href="uploads/0003.jpg"> <img src="uploads/0003.jpg" id="NCEEKI"> </a> </li> <li id="upimagesPWSHUN"> <a href="uploads/0003.jpg"> <img src="uploads/0003.jpg" id="PWSHUN"> </a> </li> <li id="upimagesOYJAQV"> <a href="uploads/0004.jpg"> <img src="uploads/0004.jpg" id="OYJAQV"> </a> </li> </ul> </div> i want to make a function in jquery too get all the images in 1 array to be able to sent the array to php! the array i want to be in this form: array( 'image_id_1' => array( 'image_src_1' => 'xyz.jpg', ) 'image_id_2' => array( 'image_src_2' => 'xyz.jpg', ) 'image_id_3' => array( 'image_src_3' => 'xyz.jpg', ) 'image_id_4' => array( 'image_src_4' => 'xyz.jpg', ) ) how i can code this? thanks

    Read the article

< Previous Page | 8 9 10 11 12 13 14  | Next Page >